malt 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. data/.ruby +156 -0
  2. data/Assembly +28 -0
  3. data/COPYING.rdoc +33 -0
  4. data/Gemfile +10 -0
  5. data/HISTORY.rdoc +102 -0
  6. data/README.rdoc +16 -10
  7. data/Reapfile +4 -0
  8. data/lib/malt.rb +36 -8
  9. data/lib/malt.yml +156 -0
  10. data/lib/malt/conversions.rb +42 -0
  11. data/lib/malt/core_ext.rb +81 -3
  12. data/lib/malt/engines/abstract.rb +259 -50
  13. data/lib/malt/engines/bluecloth.rb +19 -9
  14. data/lib/malt/engines/builder.rb +93 -32
  15. data/lib/malt/engines/coffee.rb +46 -0
  16. data/lib/malt/engines/creole.rb +60 -0
  17. data/lib/malt/engines/erb.rb +69 -44
  18. data/lib/malt/engines/erector.rb +61 -30
  19. data/lib/malt/engines/erubis.rb +41 -31
  20. data/lib/malt/engines/haml.rb +13 -37
  21. data/lib/malt/engines/kramdown.rb +40 -15
  22. data/lib/malt/engines/less.rb +15 -14
  23. data/lib/malt/engines/liquid.rb +24 -14
  24. data/lib/malt/engines/markaby.rb +44 -22
  25. data/lib/malt/engines/maruku.rb +89 -0
  26. data/lib/malt/engines/mustache.rb +20 -14
  27. data/lib/malt/engines/nokogiri.rb +89 -0
  28. data/lib/malt/engines/radius.rb +72 -34
  29. data/lib/malt/engines/ragtag.rb +26 -18
  30. data/lib/malt/engines/rdiscount.rb +18 -11
  31. data/lib/malt/engines/rdoc.rb +21 -15
  32. data/lib/malt/engines/redcarpet.rb +137 -0
  33. data/lib/malt/engines/redcloth.rb +15 -7
  34. data/lib/malt/engines/ruby.rb +13 -12
  35. data/lib/malt/engines/sass.rb +30 -17
  36. data/lib/malt/engines/string.rb +36 -0
  37. data/lib/malt/engines/tenjin.rb +70 -27
  38. data/lib/malt/engines/wikicloth.rb +48 -0
  39. data/lib/malt/formats/abstract.rb +90 -29
  40. data/lib/malt/formats/abstract_template.rb +10 -8
  41. data/lib/malt/formats/builder.rb +39 -13
  42. data/lib/malt/formats/coffee.rb +54 -0
  43. data/lib/malt/formats/css.rb +3 -3
  44. data/lib/malt/formats/erb.rb +31 -66
  45. data/lib/malt/formats/haml.rb +8 -8
  46. data/lib/malt/formats/html.rb +1 -7
  47. data/lib/malt/formats/javascript.rb +27 -0
  48. data/lib/malt/formats/latex.rb +1 -1
  49. data/lib/malt/formats/less.rb +13 -11
  50. data/lib/malt/formats/liquid.rb +7 -7
  51. data/lib/malt/formats/markdown.rb +43 -44
  52. data/lib/malt/formats/mediawiki.rb +70 -0
  53. data/lib/malt/formats/mustache.rb +5 -5
  54. data/lib/malt/formats/pdf.rb +1 -7
  55. data/lib/malt/formats/radius.rb +5 -4
  56. data/lib/malt/formats/ragtag.rb +14 -13
  57. data/lib/malt/formats/rbhtml.rb +28 -20
  58. data/lib/malt/formats/rdoc.rb +5 -4
  59. data/lib/malt/formats/rhtml.rb +19 -43
  60. data/lib/malt/formats/ruby.rb +11 -45
  61. data/lib/malt/formats/sass.rb +16 -24
  62. data/lib/malt/formats/scss.rb +13 -30
  63. data/lib/malt/formats/string.rb +61 -0
  64. data/lib/malt/formats/tenjin.rb +4 -4
  65. data/lib/malt/formats/text.rb +1 -1
  66. data/lib/malt/formats/textile.rb +7 -19
  67. data/lib/malt/kernel.rb +1 -2
  68. data/lib/malt/machine.rb +83 -13
  69. data/lib/malt/tilted.rb +216 -0
  70. data/lib/malt/version.rb +21 -0
  71. data/test/helper.rb +15 -0
  72. data/test/unit/engines/case_engine_bluecloth.rb +40 -0
  73. data/test/unit/engines/case_engine_builder.rb +30 -0
  74. data/test/unit/engines/case_engine_coffee.rb +30 -0
  75. data/test/unit/engines/case_engine_creole.rb +35 -0
  76. data/test/unit/engines/case_engine_erb.rb +28 -0
  77. data/test/unit/engines/case_engine_erector.rb +36 -0
  78. data/test/unit/engines/case_engine_erubis.rb +28 -0
  79. data/test/unit/engines/case_engine_haml.rb +30 -0
  80. data/test/unit/engines/case_engine_kramdown.rb +30 -0
  81. data/test/unit/engines/case_engine_less.rb +40 -0
  82. data/test/unit/engines/case_engine_liquid.rb +28 -0
  83. data/test/unit/engines/case_engine_markaby.rb +20 -0
  84. data/test/unit/engines/case_engine_maruku.rb +30 -0
  85. data/test/unit/engines/case_engine_mustache.rb +28 -0
  86. data/test/unit/engines/case_engine_nokogiri.rb +30 -0
  87. data/test/unit/engines/case_engine_radius.rb +30 -0
  88. data/test/unit/engines/case_engine_ragtag.rb +40 -0
  89. data/test/unit/engines/case_engine_rdiscount.rb +30 -0
  90. data/test/unit/engines/case_engine_rdoc.rb +31 -0
  91. data/test/unit/engines/case_engine_redcarpet.rb +30 -0
  92. data/test/unit/engines/case_engine_redcloth.rb +31 -0
  93. data/test/unit/engines/case_engine_ruby.rb +28 -0
  94. data/test/unit/engines/case_engine_sass.rb +36 -0
  95. data/test/unit/engines/case_engine_string.rb +28 -0
  96. data/test/unit/engines/case_engine_tenjin.rb +28 -0
  97. data/test/unit/engines/case_engine_wikicloth.rb +25 -0
  98. data/test/unit/machine.rb +27 -0
  99. data/test/unit/malt.rb +12 -0
  100. metadata +364 -266
  101. data/History.rdoc +0 -64
  102. data/License.txt +0 -205
  103. data/Syckfile +0 -80
  104. data/features/consistent_rendering.feature +0 -36
  105. data/features/samples/sample.erb +0 -1
  106. data/features/samples/sample.erubis +0 -1
  107. data/features/samples/sample.liquid +0 -1
  108. data/features/samples/sample.mustache +0 -1
  109. data/features/samples/sample.radius +0 -1
  110. data/features/step_definitions/engine_steps.rb +0 -49
  111. data/features/support/loadpath.rb +0 -1
  112. data/features/support/sample_class.rb +0 -8
  113. data/lib/malt/formats/erector.rb +0 -53
  114. data/lib/malt/formats/markaby.rb +0 -53
  115. data/lib/malt/meta/data.rb +0 -26
  116. data/lib/malt/meta/package +0 -21
  117. data/lib/malt/meta/profile +0 -21
  118. data/meta/data.rb +0 -26
  119. data/meta/package +0 -21
  120. data/meta/profile +0 -21
  121. data/qed/01_overview.rdoc +0 -8
  122. data/qed/02_formats.rdoc +0 -39
  123. data/qed/03_formats/01_overview.rdoc +0 -7
  124. data/qed/03_formats/02_rdoc.rdoc +0 -83
  125. data/qed/03_formats/03_textile.rdoc +0 -48
  126. data/qed/03_formats/04_markdown.rdoc +0 -66
  127. data/qed/03_formats/05_erb.rdoc +0 -65
  128. data/qed/03_formats/06_liquid.rdoc +0 -54
  129. data/qed/03_formats/07_haml.rdoc +0 -44
  130. data/qed/03_formats/08_ragtag.rdoc +0 -19
  131. data/qed/03_formats/09_radius.rdoc +0 -43
  132. data/qed/03_formats/11_tenjin.rdoc +0 -47
  133. data/qed/03_formats/12_rbhtml.rdoc +0 -55
  134. data/qed/03_formats/13_sass.rdoc +0 -55
  135. data/qed/03_formats/14_scss.rdoc +0 -58
  136. data/qed/03_formats/15_less.rdoc +0 -46
  137. data/qed/03_formats/16_ruby.rdoc +0 -48
  138. data/qed/03_formats/17_markaby.rdoc +0 -50
  139. data/qed/03_formats/18_builder.rb +0 -50
  140. data/qed/03_formats/19_erector.rb +0 -50
  141. data/qed/03_formats/20_mustache.rdoc +0 -54
  142. data/qed/05_machine/01_limited_formats.rdoc +0 -29
  143. data/qed/05_machine/02_prioritized_engines.rdoc +0 -34
  144. data/qed/applique/malt.rb +0 -13
  145. data/qed/samples/data.yml +0 -4
  146. data/qed/samples/output-erb.txt +0 -1
  147. data/qed/samples/output-liquid.txt +0 -1
  148. data/qed/samples/output-mustache.txt +0 -1
  149. data/qed/samples/output-radius.txt +0 -1
  150. data/qed/samples/sample.erb +0 -1
  151. data/qed/samples/sample.liquid +0 -1
  152. data/qed/samples/sample.markdown +0 -308
  153. data/qed/samples/sample.mustache +0 -1
  154. data/qed/samples/sample.radius +0 -1
  155. data/qed/samples/sample.rdoc +0 -8
@@ -1,58 +0,0 @@
1
- == SCSS
2
-
3
- Lets say we have a SCSS document called 'test.scss' containing:
4
-
5
- $blue: #3bbfce;
6
- $margin: 16px;
7
-
8
- .content-navigation {
9
- border-color: $blue;
10
- color:
11
- darken($blue, 9%);
12
- }
13
-
14
- .border {
15
- padding: $margin / 2;
16
- margin: $margin / 2;
17
- border-color: $blue;
18
- }
19
-
20
- We can render the Sass document via #render.
21
-
22
- @css = Malt.render(:file=>'tmp/test.scss')
23
-
24
- And we can verify that @css is the expected CSS:
25
-
26
- .content-navigation {
27
- border-color: #3bbfce;
28
- color: #2ca2af; }
29
-
30
- .border {
31
- padding: 8px;
32
- margin: 8px;
33
- border-color: #3bbfce; }
34
-
35
- We can also get a hold of the SCSS document via the Malt.file function.
36
-
37
- scss = Malt.file('tmp/test.scss')
38
-
39
- scss.class.assert == Malt::Format::SCSS
40
-
41
- We can convert the SCSS document to a CSS document via the #to_css method.
42
-
43
- css = scss.to_css
44
-
45
- We can see that the output is an instance of Malt::Format::SCSS.
46
-
47
- css.class.assert == Malt::Format::CSS
48
-
49
- And that by calling #to_s we can get the rendered CSS document.
50
-
51
- css.to_s.assert.include?('border-color: #3bbfce;')
52
-
53
- Or we can convert the SCSS document directly to CSS via the #css method.
54
-
55
- out = scss.css
56
-
57
- out.assert.include?('border-color: #3bbfce;')
58
-
@@ -1,46 +0,0 @@
1
- == LESS
2
-
3
- Lets say we have a LESS document called 'test.less' containing:
4
-
5
- @brand_color: #4D926F;
6
- #header {
7
- color: @brand_color;
8
- }
9
- h2 {
10
- color: @brand_color;
11
- }
12
-
13
- We can render it via Malt with #render.
14
-
15
- @css = Malt.render(:file=>'tmp/test.less')
16
-
17
- And we can verify that @css is:
18
-
19
- #header, h2 { color: #4d926f; }
20
-
21
- Look how concise that is. LESS is pretty slick.
22
-
23
- We can also get a hold of the LESS document via the Malt.file function.
24
-
25
- less = Malt.file('tmp/test.less')
26
-
27
- less.class.assert == Malt::Format::LESS
28
-
29
- We can convert the LESS document to a CSS document via the #to_css method.
30
-
31
- css = less.to_css
32
-
33
- We can see that the output is an instance of Malt::Format::HTML.
34
-
35
- css.class.assert == Malt::Format::CSS
36
-
37
- And that by calling #to_s we can get the rendered CSS document.
38
-
39
- css.to_s.assert.include?('#header, h2 { color: #4d926f; }')
40
-
41
- Or we can convert the LESS document directly to CSS via the #css method.
42
-
43
- out = less.css
44
-
45
- out.assert.include?('#header, h2 { color: #4d926f; }')
46
-
@@ -1,48 +0,0 @@
1
- == Ruby
2
-
3
- It may not seem obvious at first, but Ruby itself can be used as
4
- a template system.
5
-
6
- Lets say we have a Ruby document called 'test.rb' containing:
7
-
8
- "<h1>Example #{ title }</h1>\n" +
9
- "<p>This is an example of Ruby rendering.</p>"
10
-
11
- We can run this Ruby script thru Malt's +render+ function.
12
-
13
- data = {:title => 'Document'}
14
-
15
- html = Malt.render(:file=>'tmp/test.rb', :data=>data)
16
-
17
- Whatever was the final result of evaluating the Ruby script, converted to
18
- a string via #to_s, will be the result of the rendering.
19
-
20
- html.assert.include?('<h1>Example Document</h1>')
21
-
22
- We can get a hold of the Ruby template via the Malt.file function.
23
-
24
- ruby = Malt.file('tmp/test.rb')
25
-
26
- ruby.class.assert == Malt::Format::Ruby
27
-
28
- Ruby is a <i>universal template format</i>, so it can be converted to any other
29
- format (even if it is not really that format).
30
-
31
- data = {:title => "Document"}
32
-
33
- html = ruby.to_html(data)
34
-
35
- First we will notice that the output is an instance of Malt::Format::HTML.
36
-
37
- html.class.assert == Malt::Format::HTML
38
-
39
- And that by calling #to_s we can get the rendered HTML document.
40
-
41
- html.to_s.assert.include?('<h1>Example Document</h1>')
42
-
43
- Or we can convert the Ruby document directly to HTML via the #html method.
44
-
45
- out = ruby.html(data)
46
-
47
- out.assert.include?('<h1>Example Document</h1>')
48
-
@@ -1,50 +0,0 @@
1
- == Markaby
2
-
3
- Lets say we have a Markaby document called 'test.markaby' containing:
4
-
5
- html do
6
- h1 "Example #{@title}"
7
- p "This is an example of a Maraby template."
8
- end
9
-
10
- Notice the use of the instance variable. Markaby templates must use instance
11
- variables for data rendering in order to avoid ambiguity with the markup
12
- syntax itself.
13
-
14
- We can render Markaby documents via the +render+ method, as we can any format.
15
- Since Markaby is a template format and not just a markup syntax, so we need
16
- to also provide the +render+ function with data for interpolation into the
17
- Markaby document.
18
-
19
- data = { :title=>"Document" }
20
-
21
- html = Malt.render(:file=>'tmp/test.markaby', :data=>data)
22
-
23
- html.assert.include?('<h1>Example Document</h1>')
24
-
25
- We can get a hold of the Markaby document via the Malt.file function.
26
-
27
- markaby = Malt.file('tmp/test.markaby')
28
-
29
- markaby.class.assert == Malt::Format::Markaby
30
-
31
- We can convert Markaby documents to html very easily.
32
-
33
- data = {:title => "Document"}
34
-
35
- html = markaby.to_html(data)
36
-
37
- First we will notice that the output is an instance of Malt::Format::HTML.
38
-
39
- html.class.assert == Malt::Format::HTML
40
-
41
- And that by calling #to_s we can get the rendered HTML document.
42
-
43
- html.to_s.assert.include?('<h1>Example Document</h1>')
44
-
45
- Or we can convert the Markaby document directly to HTML via the #html method.
46
-
47
- out = markaby.html(data)
48
-
49
- out.assert.include?('<h1>Example Document</h1>')
50
-
@@ -1,50 +0,0 @@
1
- == Builder
2
-
3
- Lets say we have a Builder document called 'test.builder' containing:
4
-
5
- html do |h|
6
- h.h1 "Example #{@title}"
7
- h.p "This is an example of a Maraby template."
8
- end
9
-
10
- Notice the use of the instance variable. Builder templates must use instance
11
- variables for data rendering in order to avoid ambiguity with the markup
12
- syntax itself.
13
-
14
- We can render Builder documents via the +render+ method, as we can any format.
15
- Since Builder is a template format and not just a markup syntax, so we need
16
- to also provide the +render+ function with data for interpolation into the
17
- Builder document.
18
-
19
- data = { :title=>"Document" }
20
-
21
- html = Malt.render(:file=>'tmp/test.builder', :data=>data)
22
-
23
- html.assert.include?('<h1>Example Document</h1>')
24
-
25
- We can get a hold of the Builder document via the Malt.file function.
26
-
27
- builder = Malt.file('tmp/test.builder')
28
-
29
- builder.class.assert == Malt::Format::Builder
30
-
31
- We can convert Builder documents to html very easily.
32
-
33
- data = {:title => "Document"}
34
-
35
- html = builder.to_html(data)
36
-
37
- First we will notice that the output is an instance of Malt::Format::HTML.
38
-
39
- html.class.assert == Malt::Format::HTML
40
-
41
- And that by calling #to_s we can get the rendered HTML document.
42
-
43
- html.to_s.assert.include?('<h1>Example Document</h1>')
44
-
45
- Or we can convert the Builder document directly to HTML via the #html method.
46
-
47
- out = builder.html(data)
48
-
49
- out.assert.include?('<h1>Example Document</h1>')
50
-
@@ -1,50 +0,0 @@
1
- == Erector
2
-
3
- Lets say we have a Erector document called 'test.erector' containing:
4
-
5
- html do
6
- h1 "Example #{@title}"
7
- p "This is an example of a Maraby template."
8
- end
9
-
10
- Notice the use of the instance variable. Erector templates must use instance
11
- variables for data rendering in order to avoid ambiguity with the markup
12
- syntax itself.
13
-
14
- We can render Erector documents via the +render+ method, as we can any format.
15
- Since Erector is a template format and not just a markup syntax, so we need
16
- to also provide the +render+ function with data for interpolation into the
17
- Erector document.
18
-
19
- data = { :title=>"Document" }
20
-
21
- html = Malt.render(:file=>'tmp/test.erector', :data=>data)
22
-
23
- html.assert.include?('<h1>Example Document</h1>')
24
-
25
- We can get a hold of the Erector document via the Malt.file function.
26
-
27
- erector = Malt.file('tmp/test.erector')
28
-
29
- erector.class.assert == Malt::Format::Erector
30
-
31
- We can convert Erector documents to html very easily.
32
-
33
- data = {:title => "Document"}
34
-
35
- html = erector.to_html(data)
36
-
37
- First we will notice that the output is an instance of Malt::Format::HTML.
38
-
39
- html.class.assert == Malt::Format::HTML
40
-
41
- And that by calling #to_s we can get the rendered HTML document.
42
-
43
- html.to_s.assert.include?('<h1>Example Document</h1>')
44
-
45
- Or we can convert the Erector document directly to HTML via the #html method.
46
-
47
- out = erector.html(data)
48
-
49
- out.assert.include?('<h1>Example Document</h1>')
50
-
@@ -1,54 +0,0 @@
1
- == Mustache
2
-
3
- Lets say we have a Mustache document called 'test.mustache' containing:
4
-
5
- <h1>Example {{ title }}</h1>
6
-
7
- <p>This is an example of a Mustache template.</p>
8
-
9
- We can render mustache documents via the +render+ method, as we can any format.
10
- However, becuase Mustache is a template format and not just a markup syntax,
11
- we need to also provide the +render+ function with data for interpolation
12
- into the mustache document.
13
-
14
- data = { :title=>"Document" }
15
-
16
- html = Malt.render(:file=>'tmp/test.mustache', :data=>data)
17
-
18
- html.assert.include?('<h1>Example Document</h1>')
19
-
20
- Mustache doesn't actually care what format the document is rendered as, since it
21
- is purely a template engine that can be applied to any other format.
22
- Lets say we have a Mustache document called 'test.mustache' containing ...
23
-
24
- <h1>Example {{ title }}</h1>
25
-
26
- <p>This is an example of a Mustache template.</p>
27
-
28
- We can render erb documents to any format we wish.
29
-
30
- liq = Malt.file('tmp/test.mustache')
31
-
32
- html = liq.to_html(:title=>"Document")
33
-
34
- We will notice that the output is an instance of Malt::Format::HTML.
35
-
36
- html.class.assert == Malt::Format::HTML
37
-
38
- We will notice that the output is an instance of Malt::Format::HTML.
39
-
40
- html.class.assert == Malt::Format::HTML
41
-
42
- Then by calling #to_s we can get the rendered HTML document.
43
-
44
- html.to_s.assert.include?('<h1>Example Document</h1>')
45
-
46
- Or we can convert the document directly to HTML via the #html method.
47
-
48
- out = liq.html(:title=>"Alternate")
49
-
50
- out.assert.include?('<h1>Example Alternate</h1>')
51
-
52
- Mustache doesn't actually care what format the document is rendered as, since it
53
- is purely a template engine that can be applied to any format.
54
-
@@ -1,29 +0,0 @@
1
- == Limited Formats
2
-
3
- The Machine class makes it possible to control which formats
4
- are available for rendering.
5
-
6
- For example, let's make a Machine that only support RDoc format
7
- and no others.
8
-
9
- malt = Malt::Machine.new(:types=>[:rdoc])
10
-
11
- Now we use the `malt` machine object to handle rendering. First let's
12
- make sure that the machine is infact setup to limit formats to just RDoc.
13
-
14
- malt.formats.keys.assert = [:rdoc]
15
-
16
- malt.assert.format?('.rdoc')
17
- malt.refute.format?('.markdown')
18
-
19
- This being the case we should be able to render an RDoc file without issue.
20
-
21
- malt.render(:file=>'qed/samples/sample.rdoc')
22
-
23
- Where as another format type, though usually supported, but excluded in this
24
- case, will fail.
25
-
26
- expect Malt::NoEngineError do
27
- malt.render(:file=>'qed/samples/sample.markdown')
28
- end
29
-
@@ -1,34 +0,0 @@
1
- == Prioritized Engines
2
-
3
- The Malt Machine class can also be used to prioritize engines.
4
- For instance, by default markdown documents are handled by
5
- the RDiscount library.
6
-
7
- malt = Malt::Machine.new
8
-
9
- engine = malt.pry.engine(:markdown)
10
- engine.assert == Malt::Engine::RDiscount
11
-
12
- To use Kramdown instead, we can specify
13
- it as a priority when initilizeing a new Machine.
14
-
15
- malt = Malt::Machine.new(:priority=>[:kramdown])
16
-
17
- Lets check to make sure.
18
-
19
- engine = malt.pry.engine(:markdown)
20
- engine.assert == Malt::Engine::Kramdown
21
-
22
- To change the engine priorities of the master Malt Machine, provide
23
- the #priority method with the type and it will put it at the top of
24
- the priority list.
25
-
26
- Malt.machine.priority :kramdown
27
-
28
- Lets check to make sure.
29
-
30
- engine = Malt.machine.pry.engine(:markdown)
31
- engine.assert == Malt::Engine::Kramdown
32
-
33
- (If you are wondering, #pry is simply used to call a private method.)
34
-
@@ -1,13 +0,0 @@
1
- require 'malt'
2
- require 'ae/pry'
3
-
4
- When "say we have a (((\\w+))) document called '(((\\S+)))' containing" do |type, fname, text|
5
- file = File.join('tmp',fname)
6
- File.open(file, 'w'){ |f| f << text }
7
- end
8
-
9
- When "verify that (((.*?))) is" do |var, text|
10
- out = instance_variable_get(var)
11
- out.strip.assert == text.strip
12
- end
13
-
@@ -1,4 +0,0 @@
1
- ---
2
- name : Tom
3
- state: Florida
4
-