Sha256: 770a5ce8d2248a8adb141af91f4e61617dd2a37a2a9ff6b489a05f62603ed9ed
Contents?: true
Size: 1.3 KB
Versions: 3
Compression:
Stored size: 1.3 KB
Contents
== Tenjin While Tenjin is generally intended to be used to render HTML documents, it is a general purpose template format that can be used for any type of document. For these uses, the Tenjin file extension is '.tenjin'. Lets say we have a Tenjin document called 'test.tenjin' containing: Hello #{@name}! We can render the document via #render. data = { :name=>'World', :items=>['A','B','C'] } @text = Malt.render(:file=>'tmp/test.tenjin', :data=>data) And we can verify that @text is: Hello World! We can get a OOP interface tothe Tenjin document via the Malt.file function. tenjin = Malt.file('tmp/test.tenjin') tenjin.class.assert == Malt::Format::Tenjin Since Tenjin is aa general pupose template foramt, we can convert Tenjin documents to any format we wish. For instance we can convert our example to a Text documents via #to_txt. data = { :name=>'World', :items=>['<AAA>', 'B&B', '"CCC"'] } text = tenjin.to_txt(data) First we will notice that the output is an instance of `Malt::Format::Text`. text.class.assert == Malt::Format::Text And that by calling #to_s we can get the rendered Text document. text.to_s.assert.include?('Hello World!') Or we can convert the Tenjin document directly to text via the #txt method. out = tenjin.txt(data) out.assert.include?('Hello World!')
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
malt-0.3.0 | qed/03_formats/11_tenjin.rdoc |
malt-0.2.0 | qed/03_formats/11_tenjin.rdoc |
malt-0.1.1 | qed/03_formats/11_tenjin.rdoc |