malt 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +15 -1
- data/Syckfile +80 -0
- data/lib/malt.rb +1 -1
- data/lib/malt/config.rb +12 -0
- data/lib/malt/engines.rb +1 -1
- data/lib/malt/engines/abstract.rb +2 -2
- data/lib/malt/engines/bluecloth.rb +1 -1
- data/lib/malt/engines/erb.rb +1 -1
- data/lib/malt/engines/erubis.rb +1 -1
- data/lib/malt/engines/haml.rb +1 -1
- data/lib/malt/engines/kramdown.rb +1 -1
- data/lib/malt/engines/less.rb +1 -1
- data/lib/malt/engines/liquid.rb +1 -1
- data/lib/malt/engines/radius.rb +1 -1
- data/lib/malt/engines/rdiscount.rb +1 -1
- data/lib/malt/engines/rdoc.rb +1 -1
- data/lib/malt/engines/redcloth.rb +1 -1
- data/lib/malt/engines/rtals.rb +1 -1
- data/lib/malt/engines/ruby.rb +1 -1
- data/lib/malt/engines/sass.rb +1 -1
- data/lib/malt/engines/tenjin.rb +1 -1
- data/lib/malt/formats.rb +1 -1
- data/lib/malt/formats/abstract.rb +5 -3
- data/lib/malt/formats/abstract_template.rb +45 -0
- data/lib/malt/formats/css.rb +1 -1
- data/lib/malt/formats/erb.rb +3 -3
- data/lib/malt/formats/haml.rb +2 -2
- data/lib/malt/formats/html.rb +1 -1
- data/lib/malt/formats/latex.rb +1 -1
- data/lib/malt/formats/less.rb +2 -2
- data/lib/malt/formats/liquid.rb +2 -2
- data/lib/malt/formats/markdown.rb +4 -4
- data/lib/malt/formats/pdf.rb +1 -1
- data/lib/malt/formats/radius.rb +2 -2
- data/lib/malt/formats/rbhtml.rb +52 -0
- data/lib/malt/formats/rdoc.rb +2 -2
- data/lib/malt/formats/rhtml.rb +86 -0
- data/lib/malt/formats/rtals.rb +2 -2
- data/lib/malt/formats/ruby.rb +2 -2
- data/lib/malt/formats/sass.rb +2 -2
- data/lib/malt/formats/scss.rb +57 -0
- data/lib/malt/formats/tenjin.rb +2 -2
- data/lib/malt/formats/text.rb +1 -1
- data/lib/malt/formats/textile.rb +2 -2
- data/lib/malt/formats/yaml.rb +1 -1
- data/lib/malt/markup.rb +9 -0
- data/lib/malt/meta/gemfile +2 -2
- data/lib/malt/render.rb +65 -0
- data/lib/malt/template.rb +12 -0
- data/meta/gemfile +2 -2
- data/qed/01_overview.rdoc +6 -42
- data/qed/02_formats.rdoc +39 -0
- data/qed/03_formats/01_overview.rdoc +7 -0
- data/qed/03_formats/02_rdoc.rdoc +83 -0
- data/qed/03_formats/03_textile.rdoc +48 -0
- data/qed/03_formats/04_markdown.rdoc +66 -0
- data/qed/03_formats/05_erb.rdoc +65 -0
- data/qed/03_formats/06_liquid.rdoc +54 -0
- data/qed/03_formats/07_haml.rdoc +44 -0
- data/qed/03_formats/08_rtal.rdoc +15 -0
- data/qed/03_formats/09_radius.rdoc +43 -0
- data/qed/03_formats/11_tenjin.rdoc +47 -0
- data/qed/03_formats/12_rbhtml.rdoc +55 -0
- data/qed/03_formats/13_sass.rdoc +55 -0
- data/qed/03_formats/14_scss.rdoc +58 -0
- data/qed/03_formats/15_less.rdoc +46 -0
- data/qed/03_formats/16_ruby.rdoc +48 -0
- data/qed/samples/data.yml +4 -0
- data/qed/samples/output-erb.txt +1 -0
- data/qed/samples/output-liquid.txt +1 -0
- data/qed/samples/output-mustache.txt +1 -0
- data/qed/samples/output-radius.txt +1 -0
- data/qed/samples/sample.erb +1 -0
- data/qed/samples/sample.liquid +1 -0
- data/qed/samples/sample.mustache +1 -0
- data/qed/samples/sample.radius +1 -0
- data/test/samples/sample.md +308 -0
- data/test/samples/sample.rdoc +8 -0
- metadata +40 -4
data/meta/gemfile
CHANGED
data/qed/01_overview.rdoc
CHANGED
@@ -1,44 +1,8 @@
|
|
1
|
-
=
|
1
|
+
= Introduction
|
2
2
|
|
3
|
-
Malt is a multi-template rendering framework.
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
= Example
|
10
|
-
|
11
|
-
This is an example of RDOC rendering.
|
12
|
-
|
13
|
-
We can convert RDoc documents to html using the universal, functional
|
14
|
-
interface easily enough.
|
15
|
-
|
16
|
-
html = Malt.render(:file=>'tmp/test.rdoc')
|
17
|
-
|
18
|
-
In this example, Malt recognizes the type of file by the '.rdoc' extension
|
19
|
-
and renders it using the default redering engine (in this case RDoc itself).
|
20
|
-
By default the engine renders to HTML, so we did not need to specify
|
21
|
-
the output :format option to the +render+ method.
|
22
|
-
|
23
|
-
Alternately we can use the object-oriented interface.
|
24
|
-
|
25
|
-
rdoc = Malt.file('tmp/test.rdoc')
|
26
|
-
|
27
|
-
First we will notice that the output is an instance of Malt::Formats::HTML.
|
28
|
-
|
29
|
-
rdoc.class.assert == Malt::Formats::RDoc
|
30
|
-
|
31
|
-
While we could have used `Malt::Formats::RDoc.new` to create the object directly,
|
32
|
-
Malt provides the #file, as well as #text, methods for convience. We can convert
|
33
|
-
the rdoc to html with the #to_html method.
|
34
|
-
|
35
|
-
html = rdoc.to_html
|
36
|
-
|
37
|
-
Again notice that the output is an instance of Malt::Formats::HTML.
|
38
|
-
|
39
|
-
html.class.assert == Malt::Formats::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</h1>')
|
3
|
+
Malt is a multi-template rendering framework. It provides two convenient
|
4
|
+
interfaces for working with backend template systems. The first is
|
5
|
+
a functional interface via `Malt.render` method. And the second is an
|
6
|
+
object-oriented interface that can be easily constructed via the
|
7
|
+
`Malt.file` or `Malt.text` methods.
|
44
8
|
|
data/qed/02_formats.rdoc
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
= Formats
|
2
|
+
|
3
|
+
We have created a set of sample documents in the samples directory.
|
4
|
+
We will take each format in turn.
|
5
|
+
|
6
|
+
formats = %w{erb liquid}
|
7
|
+
|
8
|
+
Included with the format samples are files containing the expected results
|
9
|
+
of each rendering.
|
10
|
+
|
11
|
+
expected_output = {}
|
12
|
+
|
13
|
+
formats.each do |format|
|
14
|
+
expected_output[format] = File.read("qed/samples/output-#{format}.txt")
|
15
|
+
end
|
16
|
+
|
17
|
+
The data to inject into the formats that interpolate, is also stored in the
|
18
|
+
samples folder.
|
19
|
+
|
20
|
+
data = YAML.load(File.new('qed/samples/data.yml'))
|
21
|
+
|
22
|
+
Now we can render each of thes formats, and verify we get the expected result.
|
23
|
+
|
24
|
+
formats.each do |format|
|
25
|
+
output = Malt.render(:file=>"qed/samples/sample.#{format}", :format=>format, :data=>data)
|
26
|
+
output.assert == expected_output[format]
|
27
|
+
end
|
28
|
+
|
29
|
+
Notice that formats the do not use interpolation data simply ignore it even
|
30
|
+
if it is given.
|
31
|
+
|
32
|
+
We can also handle the files in a more object-oriented manner.
|
33
|
+
|
34
|
+
formats.each do |format|
|
35
|
+
object = Malt.file("qed/samples/sample.#{format}", :format=>format)
|
36
|
+
output = object.render(data)
|
37
|
+
output.assert == expected_output[format]
|
38
|
+
end
|
39
|
+
|
@@ -0,0 +1,7 @@
|
|
1
|
+
= Formats
|
2
|
+
|
3
|
+
Malt support a wide variety of markup and template systems.
|
4
|
+
|
5
|
+
Malt provides two distinct APIs for rendering each format --a single-point-of-entry
|
6
|
+
functional interface, `Malt.render`, and an object-oriented interface where by
|
7
|
+
each format is represented by a document class.
|
@@ -0,0 +1,83 @@
|
|
1
|
+
== RDoc
|
2
|
+
|
3
|
+
Lets say we have a RDoc document called 'test.rdoc' containing:
|
4
|
+
|
5
|
+
= Example
|
6
|
+
|
7
|
+
This is an example of RDoc rendering.
|
8
|
+
|
9
|
+
We can convert rdoc documents to html easily via the univeral +render+ function.
|
10
|
+
|
11
|
+
html = Malt.render(:file=>'tmp/test.rdoc')
|
12
|
+
|
13
|
+
html.assert.include?('<h1>Example</h1>')
|
14
|
+
|
15
|
+
Malt recognizes the type of file by the '.rdoc' extension and renders it using
|
16
|
+
the default redering engine (in this case RDoc itself). By default the engine
|
17
|
+
renders to HTML, so we did not need to specify the output :format option to
|
18
|
+
the +render+ method.
|
19
|
+
|
20
|
+
If we have a file that has a different extension, but is in fact an RDoc
|
21
|
+
document, we can inform Malt.
|
22
|
+
|
23
|
+
Lets say we have an RDoc document called 'test.txt' containing:
|
24
|
+
|
25
|
+
= Example
|
26
|
+
|
27
|
+
This is an example of RDoc rendering.
|
28
|
+
|
29
|
+
We can inform Malt as the actual type using the `:type` option.
|
30
|
+
|
31
|
+
html = Malt.render(:file=>'tmp/test.txt', :type=>:rdoc)
|
32
|
+
|
33
|
+
html.assert.include?('<h1>Example</h1>')
|
34
|
+
|
35
|
+
Alternately we can use the object-oriented interface. Again, lets say we have
|
36
|
+
an RDoc document called 'test.rdoc' containing ...
|
37
|
+
|
38
|
+
= Example
|
39
|
+
|
40
|
+
This is an example of RDOC rendering.
|
41
|
+
|
42
|
+
Then we can use the `Malt.file` method to instantiate an RDoc object.
|
43
|
+
|
44
|
+
rdoc = Malt.file('tmp/test.rdoc')
|
45
|
+
|
46
|
+
We will notice that the output is an instance of Malt::Formats::HTML.
|
47
|
+
|
48
|
+
rdoc.class.assert == Malt::Format::RDoc
|
49
|
+
|
50
|
+
While we could have used `Malt::Formats::RDoc.new` to create the object directly,
|
51
|
+
Malt provides the #file, as well as #text, methods for convience. We can convert
|
52
|
+
the rdoc to html with the #to_html method.
|
53
|
+
|
54
|
+
html = rdoc.to_html
|
55
|
+
|
56
|
+
Again notice that the output is an instance of Malt::Format::HTML.
|
57
|
+
|
58
|
+
html.class.assert == Malt::Format::HTML
|
59
|
+
|
60
|
+
And that by calling #to_s we can get the rendered HTML document.
|
61
|
+
|
62
|
+
html.to_s.assert.include?('<h1>Example</h1>')
|
63
|
+
|
64
|
+
We can convert rdoc documents to html very easily.
|
65
|
+
|
66
|
+
rdoc = Malt.file('tmp/test.rdoc')
|
67
|
+
|
68
|
+
html = rdoc.to_html
|
69
|
+
|
70
|
+
First we will notice that the output is an instance of Malt::Format::HTML.
|
71
|
+
|
72
|
+
html.class.assert == Malt::Format::HTML
|
73
|
+
|
74
|
+
And that by calling #to_s we can get the rendered HTML document.
|
75
|
+
|
76
|
+
html.to_s.assert.include?('<h1>Example</h1>')
|
77
|
+
|
78
|
+
Or we can convert the RDoc document directly to HTML via the #html method.
|
79
|
+
|
80
|
+
out = rdoc.html
|
81
|
+
|
82
|
+
out.assert.include?('<h1>Example</h1>')
|
83
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
== Textile
|
2
|
+
|
3
|
+
Malt supports Textile via RedCloth.
|
4
|
+
|
5
|
+
Lets say we have a Textile document called 'test.tt' containing ...
|
6
|
+
|
7
|
+
h1. Example
|
8
|
+
|
9
|
+
This is an example of Textile rendering.
|
10
|
+
|
11
|
+
We can redner the textile document via the universal render function.
|
12
|
+
Textile documents are recognized by the +.textile+ or +.tt+ extension.
|
13
|
+
|
14
|
+
html = Malt.render(:file=>'tmp/test.tt')
|
15
|
+
|
16
|
+
html.assert.include?('<h1>Example</h1>')
|
17
|
+
|
18
|
+
Malt supports Textile via either the RedCloth or the ___ backend.
|
19
|
+
|
20
|
+
Lets say we have an Textile document called 'test.tt' containing ...
|
21
|
+
|
22
|
+
h1. Example
|
23
|
+
|
24
|
+
This is an example of Textile rendering.
|
25
|
+
|
26
|
+
We can access the file via the +Malt.file+ method. Textile documents are
|
27
|
+
recognized by the +.textile+ or +.tt+ extension.
|
28
|
+
|
29
|
+
tile = Malt.file('tmp/test.tt')
|
30
|
+
|
31
|
+
We can the convert the document to a Malt Html object via the #to_html method.
|
32
|
+
|
33
|
+
html = tile.to_html
|
34
|
+
|
35
|
+
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</h1>')
|
42
|
+
|
43
|
+
Or we can convert the document directly to HTML via the #html method.
|
44
|
+
|
45
|
+
out = tile.html
|
46
|
+
|
47
|
+
out.assert.include?('<h1>Example</h1>')
|
48
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
== Markdown
|
2
|
+
|
3
|
+
Malt supports Markdown via either the RDiscount, BlueCloth or Kramdown backends.
|
4
|
+
|
5
|
+
Lets say we have a Markdown document called 'test.md' containing ...
|
6
|
+
|
7
|
+
# Example
|
8
|
+
|
9
|
+
This is an example of Markdown rendering.
|
10
|
+
|
11
|
+
Markdown documents are recognized by the +.markdown+ or +.md+ file extensions.
|
12
|
+
|
13
|
+
html = Malt.render(:file=>'tmp/test.md')
|
14
|
+
|
15
|
+
html.assert.include?('<h1>Example</h1>')
|
16
|
+
|
17
|
+
By default teh RDiscount library is used to render markdown documents, but
|
18
|
+
Malt supports BlueCloth and Kramdown as well. These case be used by setting
|
19
|
+
the :engine option.
|
20
|
+
|
21
|
+
html = Malt.render(:file=>'tmp/test.md', :engine=>:bluecloth)
|
22
|
+
|
23
|
+
And as we can see the document rendered as expected.
|
24
|
+
|
25
|
+
html.assert.include?('<h1>Example</h1>')
|
26
|
+
|
27
|
+
And using the Kramdown library,
|
28
|
+
|
29
|
+
html = Malt.render(:file=>'tmp/test.md', :engine=>:kramdown)
|
30
|
+
|
31
|
+
We can see the document rendered as well, though notice that Kramdown provides
|
32
|
+
some bonus features compared to the other rendering engines.
|
33
|
+
|
34
|
+
html.assert.include?('<h1 id="example">Example</h1>')
|
35
|
+
|
36
|
+
Malt supports Markdown via either the RDiscount, BlueCloth or Kramdown backends.
|
37
|
+
|
38
|
+
Lets say we have an Markdown document called 'test.md' containing ...
|
39
|
+
|
40
|
+
# Example
|
41
|
+
|
42
|
+
This is an example of Markdown rendering.
|
43
|
+
|
44
|
+
We can access the file via the +Malt.file+ method. Markdown documents are
|
45
|
+
recognized by the +.markdown+ or +.md+ file extensions.
|
46
|
+
|
47
|
+
mark = Malt.file('tmp/test.md')
|
48
|
+
|
49
|
+
We can the convert the document to a Malt Html object via the #to_html method.
|
50
|
+
|
51
|
+
html = mark.to_html
|
52
|
+
|
53
|
+
Notice that the output is an instance of Malt::Format::HTML.
|
54
|
+
|
55
|
+
html.class.assert == Malt::Format::HTML
|
56
|
+
|
57
|
+
And that by calling #to_s we can get the rendered HTML document.
|
58
|
+
|
59
|
+
html.to_s.assert.include?('<h1>Example</h1>')
|
60
|
+
|
61
|
+
Or we can convert the document directly to HTML via the #html method.
|
62
|
+
|
63
|
+
out = mark.html
|
64
|
+
|
65
|
+
out.assert.include?('<h1>Example</h1>')
|
66
|
+
|
@@ -0,0 +1,65 @@
|
|
1
|
+
== ERB
|
2
|
+
|
3
|
+
Malt supports ERB via the ERB and Erubis engines.
|
4
|
+
|
5
|
+
Lets say we have a ERB document called 'test.erb' containing ...
|
6
|
+
|
7
|
+
<h1>Example <%= title %></h1>
|
8
|
+
|
9
|
+
<p>This is an example of ERB template.</p>
|
10
|
+
|
11
|
+
We can render erb documents via the +render+ method, as we can any format.
|
12
|
+
However, becuase ERB if a template format and not just a markup syntax,
|
13
|
+
we need to also provide the +render+ methods with data for interpolation
|
14
|
+
into the ERB document.
|
15
|
+
|
16
|
+
data = { :title=>"Document" }
|
17
|
+
|
18
|
+
html = Malt.render(:file=>'tmp/test.erb', :data=>data)
|
19
|
+
|
20
|
+
And as we can see the document rendered as expected.
|
21
|
+
|
22
|
+
html.assert.include?('<h1>Example Document</h1>')
|
23
|
+
|
24
|
+
ERB doesn't actually care what format the document is rendered as. The
|
25
|
+
template could have been any text file what so ever, so using the `:format`
|
26
|
+
option would have no effect here.
|
27
|
+
|
28
|
+
By default the common ERB library is used to render erb documents. By setting
|
29
|
+
the :engine option, Erubis can be used instead.
|
30
|
+
|
31
|
+
html = Malt.render(:file=>'tmp/test.erb', :data=>data, :engine=>:erubis)
|
32
|
+
|
33
|
+
And as we can see the document rendered as expected.
|
34
|
+
|
35
|
+
html.assert.include?('<h1>Example Document</h1>')
|
36
|
+
|
37
|
+
Malt supports template engines as well as formats.
|
38
|
+
|
39
|
+
Lets say we have an ERB document called 'test.erb' containing ...
|
40
|
+
|
41
|
+
<h1>Example <%= title %></h1>
|
42
|
+
|
43
|
+
<p>This is an example of ERB template.</p>
|
44
|
+
|
45
|
+
We can render erb documents to any format we wish.
|
46
|
+
|
47
|
+
erb = Malt.file('tmp/test.erb')
|
48
|
+
|
49
|
+
html = erb.to_html(:title=>"Document")
|
50
|
+
|
51
|
+
We will notice that the output is an instance of Malt::Format::HTML.
|
52
|
+
|
53
|
+
html.class.assert == Malt::Format::HTML
|
54
|
+
|
55
|
+
And that by calling #to_s we can get the rendered HTML document.
|
56
|
+
|
57
|
+
html.to_s.assert.include?('<h1>Example Document</h1>')
|
58
|
+
|
59
|
+
Or we can convert the document directly to HTML via the #html method.
|
60
|
+
|
61
|
+
out = erb.html(:title=>"Alternate")
|
62
|
+
|
63
|
+
out.assert.include?('<h1>Example Alternate</h1>')
|
64
|
+
|
65
|
+
ERB doesn't actually care what format the document is rendered as.
|
@@ -0,0 +1,54 @@
|
|
1
|
+
== Liquid
|
2
|
+
|
3
|
+
Lets say we have a Liquid document called 'test.liquid' containing:
|
4
|
+
|
5
|
+
<h1>Example {{ title }}</h1>
|
6
|
+
|
7
|
+
<p>This is an example of a Liquid template.</p>
|
8
|
+
|
9
|
+
We can render liquid documents via the +render+ method, as we can any format.
|
10
|
+
However, becuase Liquid 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 liquid document.
|
13
|
+
|
14
|
+
data = { :title=>"Document" }
|
15
|
+
|
16
|
+
html = Malt.render(:file=>'tmp/test.liquid', :data=>data)
|
17
|
+
|
18
|
+
html.assert.include?('<h1>Example Document</h1>')
|
19
|
+
|
20
|
+
Liquid 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 Liquid document called 'test.liquid' containing ...
|
23
|
+
|
24
|
+
<h1>Example {{ title }}</h1>
|
25
|
+
|
26
|
+
<p>This is an example of a Liquid template.</p>
|
27
|
+
|
28
|
+
We can render erb documents to any format we wish.
|
29
|
+
|
30
|
+
liq = Malt.file('tmp/test.liquid')
|
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
|
+
Liquid 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
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
== Haml
|
2
|
+
|
3
|
+
Lets say we have a Haml document called 'test.haml' containing:
|
4
|
+
|
5
|
+
%h1== Example #{title}
|
6
|
+
%p This is an example of a Haml template.
|
7
|
+
|
8
|
+
We can render Haml documents via the +render+ method, as we can any format.
|
9
|
+
While it might not appear as such on first glance, Haml is actually a template
|
10
|
+
format and not just a markup language, so we need to also provide the +render+
|
11
|
+
function with data for interpolation into the Haml document.
|
12
|
+
|
13
|
+
data = { :title=>"Document" }
|
14
|
+
|
15
|
+
html = Malt.render(:file=>'tmp/test.haml', :data=>data)
|
16
|
+
|
17
|
+
html.assert.include?('<h1>Example Document</h1>')
|
18
|
+
|
19
|
+
We can get a hold of the Haml document via the Malt.file function.
|
20
|
+
|
21
|
+
haml = Malt.file('tmp/test.haml')
|
22
|
+
|
23
|
+
haml.class.assert == Malt::Format::Haml
|
24
|
+
|
25
|
+
We can convert Haml documents to html very easily.
|
26
|
+
|
27
|
+
data = {:title => "Document"}
|
28
|
+
|
29
|
+
html = haml.to_html(data)
|
30
|
+
|
31
|
+
First we will notice that the output is an instance of Malt::Format::HTML.
|
32
|
+
|
33
|
+
html.class.assert == Malt::Format::HTML
|
34
|
+
|
35
|
+
And that by calling #to_s we can get the rendered HTML document.
|
36
|
+
|
37
|
+
html.to_s.assert.include?('<h1>Example Document</h1>')
|
38
|
+
|
39
|
+
Or we can convert the Haml document directly to HTML via the #html method.
|
40
|
+
|
41
|
+
out = haml.html(data)
|
42
|
+
|
43
|
+
out.assert.include?('<h1>Example Document</h1>')
|
44
|
+
|