tenjin 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.txt +54 -0
  3. data/benchmark/bench.rb +502 -0
  4. data/benchmark/bench_context.rb +17 -0
  5. data/benchmark/bench_context.yaml +141 -0
  6. data/benchmark/templates/_footer.html +4 -0
  7. data/benchmark/templates/_header.html +52 -0
  8. data/benchmark/templates/bench_eruby.rhtml +29 -0
  9. data/benchmark/templates/bench_tenjin.rbhtml +29 -0
  10. data/bin/rbtenjin +449 -0
  11. data/doc-api/classes/Tenjin.html +141 -0
  12. data/doc-api/classes/Tenjin/ArrayBufferTemplate.html +270 -0
  13. data/doc-api/classes/Tenjin/BaseContext.html +312 -0
  14. data/doc-api/classes/Tenjin/Context.html +126 -0
  15. data/doc-api/classes/Tenjin/ContextHelper.html +433 -0
  16. data/doc-api/classes/Tenjin/Engine.html +616 -0
  17. data/doc-api/classes/Tenjin/ErubisTemplate.html +166 -0
  18. data/doc-api/classes/Tenjin/HtmlHelper.html +359 -0
  19. data/doc-api/classes/Tenjin/Preprocessor.html +242 -0
  20. data/doc-api/classes/Tenjin/Template.html +916 -0
  21. data/doc-api/created.rid +1 -0
  22. data/doc-api/files/README_txt.html +185 -0
  23. data/doc-api/files/lib/tenjin_rb.html +136 -0
  24. data/doc-api/fr_class_index.html +36 -0
  25. data/doc-api/fr_file_index.html +28 -0
  26. data/doc-api/fr_method_index.html +89 -0
  27. data/doc-api/index.html +24 -0
  28. data/doc-api/rdoc-style.css +208 -0
  29. data/doc/docstyle.css +188 -0
  30. data/doc/examples.html +312 -0
  31. data/doc/faq.html +909 -0
  32. data/doc/users-guide.html +1691 -0
  33. data/lib/tenjin.rb +959 -0
  34. data/setup.rb +1331 -0
  35. data/tenjin.gemspec +58 -0
  36. data/test/assert-text-equal.rb +45 -0
  37. data/test/data/examples/form/create.rbhtml +4 -0
  38. data/test/data/examples/form/form.rbhtml +14 -0
  39. data/test/data/examples/form/layout.rbhtml +8 -0
  40. data/test/data/examples/form/main.rb +9 -0
  41. data/test/data/examples/form/main.result +21 -0
  42. data/test/data/examples/form/update.rbhtml +4 -0
  43. data/test/data/examples/preprocessing/helper.rb +16 -0
  44. data/test/data/examples/preprocessing/main.rb +11 -0
  45. data/test/data/examples/preprocessing/main.result +17 -0
  46. data/test/data/examples/preprocessing/select.rbhtml +15 -0
  47. data/test/data/examples/preprocessing/select_P.result +18 -0
  48. data/test/data/examples/table/table.rb +9 -0
  49. data/test/data/examples/table/table.rbhtml +16 -0
  50. data/test/data/examples/table/table.result +20 -0
  51. data/test/data/examples/table/table_s.result +18 -0
  52. data/test/data/faq/ex1.rbhtml +5 -0
  53. data/test/data/faq/ex10-baselayout.rbhtml +27 -0
  54. data/test/data/faq/ex10-content.rbhtml +12 -0
  55. data/test/data/faq/ex10-customlayout.rbhtml +11 -0
  56. data/test/data/faq/ex10_inherit.result +25 -0
  57. data/test/data/faq/ex11-bench.rb +28 -0
  58. data/test/data/faq/ex11-content.rbhtml +9 -0
  59. data/test/data/faq/ex11-layout1.rbhtml +5 -0
  60. data/test/data/faq/ex11-layout2.rbhtml +6 -0
  61. data/test/data/faq/ex11.rb +5 -0
  62. data/test/data/faq/ex11.rbhtml +8 -0
  63. data/test/data/faq/ex11.source +11 -0
  64. data/test/data/faq/ex11_arraybuffer.result +15 -0
  65. data/test/data/faq/ex1_chksyntax.result +3 -0
  66. data/test/data/faq/ex2-content.rbhtml +3 -0
  67. data/test/data/faq/ex2-layout.rbhtml +11 -0
  68. data/test/data/faq/ex2_removenl.result +19 -0
  69. data/test/data/faq/ex3.rb +4 -0
  70. data/test/data/faq/ex3.rbhtml +1 -0
  71. data/test/data/faq/ex3_escapefunc1.result +2 -0
  72. data/test/data/faq/ex3_escapefunc2.result +2 -0
  73. data/test/data/faq/ex5.rbhtml +7 -0
  74. data/test/data/faq/ex5_template_args.source +9 -0
  75. data/test/data/faq/ex6-content.rhtml +6 -0
  76. data/test/data/faq/ex6-layout.rhtml +6 -0
  77. data/test/data/faq/ex6.rb +10 -0
  78. data/test/data/faq/ex6_eruby.result +12 -0
  79. data/test/data/faq/ex7-expr-pattern.rb +34 -0
  80. data/test/data/faq/ex7-expr-pattern.rbhtml +3 -0
  81. data/test/data/faq/ex7_expr_pattern.result +4 -0
  82. data/test/data/faq/ex8-m18n.rb +77 -0
  83. data/test/data/faq/ex8-m18n.rbhtml +4 -0
  84. data/test/data/faq/ex8_m18n.result +10 -0
  85. data/test/data/faq/ex9-baselayout.rbhtml +8 -0
  86. data/test/data/faq/ex9-content.rbhtml +6 -0
  87. data/test/data/faq/ex9-mylayout.rbhtml +5 -0
  88. data/test/data/faq/ex9_changelayout.result +11 -0
  89. data/test/data/users_guide/content6.rbhtml +3 -0
  90. data/test/data/users_guide/content7.rbhtml +5 -0
  91. data/test/data/users_guide/content8.rbhtml +2 -0
  92. data/test/data/users_guide/contextdata.rb +7 -0
  93. data/test/data/users_guide/datafile.rb +5 -0
  94. data/test/data/users_guide/datafile.yaml +10 -0
  95. data/test/data/users_guide/ex.rbhtml +6 -0
  96. data/test/data/users_guide/ex.result +7 -0
  97. data/test/data/users_guide/ex.script +5 -0
  98. data/test/data/users_guide/ex_script.result +7 -0
  99. data/test/data/users_guide/ex_source.result +8 -0
  100. data/test/data/users_guide/example1.rbhtml +12 -0
  101. data/test/data/users_guide/example1.result +17 -0
  102. data/test/data/users_guide/example10.rbhtml +4 -0
  103. data/test/data/users_guide/example10_template_args.result +6 -0
  104. data/test/data/users_guide/example11.rbhtml +5 -0
  105. data/test/data/users_guide/example11_template_args_result +2 -0
  106. data/test/data/users_guide/example12.rbhtml +12 -0
  107. data/test/data/users_guide/example12_preprocessed.result +10 -0
  108. data/test/data/users_guide/example12_preprocessed_source.result +10 -0
  109. data/test/data/users_guide/example13.rbhtml +6 -0
  110. data/test/data/users_guide/example13_preprocessed.result +2 -0
  111. data/test/data/users_guide/example13_preprocessed_source.result +2 -0
  112. data/test/data/users_guide/example14.rb +32 -0
  113. data/test/data/users_guide/example14.rbhtml +6 -0
  114. data/test/data/users_guide/example14_tmplclass.result +15 -0
  115. data/test/data/users_guide/example15.rb +10 -0
  116. data/test/data/users_guide/example15_escapefunc.result +14 -0
  117. data/test/data/users_guide/example16.rbhtml +4 -0
  118. data/test/data/users_guide/example16a.rb +10 -0
  119. data/test/data/users_guide/example16a.result +4 -0
  120. data/test/data/users_guide/example16b.rb +13 -0
  121. data/test/data/users_guide/example16b.result +4 -0
  122. data/test/data/users_guide/example16c.rb +12 -0
  123. data/test/data/users_guide/example16c.result +4 -0
  124. data/test/data/users_guide/example1_S.result +14 -0
  125. data/test/data/users_guide/example1_SXNC.result +10 -0
  126. data/test/data/users_guide/example1_source.result +14 -0
  127. data/test/data/users_guide/example2.rbhtml +3 -0
  128. data/test/data/users_guide/example2_sb.result2 +9 -0
  129. data/test/data/users_guide/example3.rbhtml +5 -0
  130. data/test/data/users_guide/example3_syntaxcheck.result +2 -0
  131. data/test/data/users_guide/example4.rbhtml +13 -0
  132. data/test/data/users_guide/example4_datafile_rb.result +13 -0
  133. data/test/data/users_guide/example4_yaml.result +13 -0
  134. data/test/data/users_guide/example5.rbhtml +9 -0
  135. data/test/data/users_guide/example5_datastr_rb.result +9 -0
  136. data/test/data/users_guide/example5_datastr_yaml.result +9 -0
  137. data/test/data/users_guide/example6.rbhtml +19 -0
  138. data/test/data/users_guide/example6_layout.result +29 -0
  139. data/test/data/users_guide/example6_nested.result +28 -0
  140. data/test/data/users_guide/example7_layout2.result +13 -0
  141. data/test/data/users_guide/example8_layout3.result +8 -0
  142. data/test/data/users_guide/example9.rbhtml +18 -0
  143. data/test/data/users_guide/example9_capture.result +26 -0
  144. data/test/data/users_guide/footer.html +5 -0
  145. data/test/data/users_guide/footer.rbhtml +4 -0
  146. data/test/data/users_guide/layout6.rbhtml +17 -0
  147. data/test/data/users_guide/layout7.rbhtml +9 -0
  148. data/test/data/users_guide/layout8_html.rbhtml +5 -0
  149. data/test/data/users_guide/layout8_xhtml.rbhtml +6 -0
  150. data/test/data/users_guide/layout9.rbhtml +25 -0
  151. data/test/data/users_guide/sidemenu.rbhtml +5 -0
  152. data/test/data/users_guide/user_app.cgi +39 -0
  153. data/test/data/users_guide/user_app.result +30 -0
  154. data/test/data/users_guide/user_create.rbhtml +6 -0
  155. data/test/data/users_guide/user_edit.rbhtml +7 -0
  156. data/test/data/users_guide/user_form.rbhtml +10 -0
  157. data/test/data/users_guide/user_layout.rbhtml +16 -0
  158. data/test/test_all.rb +23 -0
  159. data/test/test_engine.rb +526 -0
  160. data/test/test_engine.yaml +2039 -0
  161. data/test/test_examples.rb +81 -0
  162. data/test/test_faq.rb +60 -0
  163. data/test/test_htmlhelper.rb +78 -0
  164. data/test/test_main.rb +564 -0
  165. data/test/test_main.yaml +174 -0
  166. data/test/test_template.rb +113 -0
  167. data/test/test_template.yaml +1244 -0
  168. data/test/test_users_guide.rb +75 -0
  169. data/test/testcase-helper.rb +166 -0
  170. metadata +226 -0
@@ -0,0 +1,5 @@
1
+ require 'tenjin'
2
+ engine = Tenjin::Engine.new()
3
+ context = { :name=>'World', :items=>['<AAA>', 'B&B', '"CCC"'] }
4
+ output = engine.render('ex.rbhtml', context)
5
+ print output
@@ -0,0 +1,7 @@
1
+ $ ruby ex.script
2
+ Hello World!
3
+ <ul>
4
+ <li>&lt;AAA&gt;</li>
5
+ <li>B&amp;B</li>
6
+ <li>&quot;CCC&quot;</li>
7
+ </ul>
@@ -0,0 +1,8 @@
1
+ $ rbtenjin -s ex.rbhtml
2
+ _buf = ''; _buf << %Q`Hello #{@name}!
3
+ <ul>\n`
4
+ for item in @items
5
+ _buf << %Q` <li>#{escape((item).to_s)}</li>\n`
6
+ end
7
+ _buf << %Q`</ul>\n`
8
+ _buf.to_s
@@ -0,0 +1,12 @@
1
+ <table>
2
+ <tbody>
3
+ <?rb i = 0 ?>
4
+ <?rb for item in ['<foo>', 'bar&bar', '"baz"'] ?>
5
+ <?rb i += 1 ?>
6
+ <tr>
7
+ <td>#{item}</td>
8
+ <td>${item}</td>
9
+ </tr>
10
+ <?rb end ?>
11
+ <tbody>
12
+ </table>
@@ -0,0 +1,17 @@
1
+ $ rbtenjin example1.rbhtml
2
+ <table>
3
+ <tbody>
4
+ <tr>
5
+ <td><foo></td>
6
+ <td>&lt;foo&gt;</td>
7
+ </tr>
8
+ <tr>
9
+ <td>bar&bar</td>
10
+ <td>bar&amp;bar</td>
11
+ </tr>
12
+ <tr>
13
+ <td>"baz"</td>
14
+ <td>&quot;baz&quot;</td>
15
+ </tr>
16
+ <tbody>
17
+ </table>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0"?>
2
+ <?rb #@ARGS title, name ?>
3
+ <h1>${title}</h1>
4
+ <p>Hello ${name}!</p>
@@ -0,0 +1,6 @@
1
+ $ rbtenjin -s example10.rbhtml
2
+ _buf = ''; _buf << %Q`<?xml version="1.0"?>\n`
3
+ title = @title; name = @name;
4
+ _buf << %Q`<h1>#{escape((title).to_s)}</h1>
5
+ <p>Hello #{escape((name).to_s)}!</p>\n`
6
+ _buf.to_s
@@ -0,0 +1,5 @@
1
+ <p>
2
+ <?rb #@ARGS x ?>
3
+ x = #{x}
4
+ y = #{y} # NameError
5
+ </p>
@@ -0,0 +1,2 @@
1
+ $ rbtenjin -c '@x=10;@y=20' example11.rbhtml
2
+ example12.rbhtml:4:in `_render': undefined local variable or method `y' (NameError)
@@ -0,0 +1,12 @@
1
+ <?RB states = { "CA" => "California", ?>
2
+ <?RB "NY" => "New York", ?>
3
+ <?RB "FL" => "Florida", ?>
4
+ <?RB "TX" => "Texas", ?>
5
+ <?RB "HI" => "Hawaii", } ?>
6
+ <?rb chk = { @params['state'] => ' selected="selected"' } ?>
7
+ <select name="state">
8
+ <option value="">-</option>
9
+ <?RB for code in states.keys.sort ?>
10
+ <option value="#{{code}}"#{chk[#{{code.inspect}}]}>${{states[code]}}</option>
11
+ <?RB end ?>
12
+ </select>
@@ -0,0 +1,10 @@
1
+ $ rbtenjin -P example12.rbhtml
2
+ <?rb chk = { @params['state'] => ' selected="selected"' } ?>
3
+ <select name="state">
4
+ <option value="">-</option>
5
+ <option value="CA"#{chk["CA"]}>California</option>
6
+ <option value="FL"#{chk["FL"]}>Florida</option>
7
+ <option value="HI"#{chk["HI"]}>Hawaii</option>
8
+ <option value="NY"#{chk["NY"]}>New York</option>
9
+ <option value="TX"#{chk["TX"]}>Texas</option>
10
+ </select>
@@ -0,0 +1,10 @@
1
+ $ rbtenjin --preprocess -sb example12.rbhtml
2
+ chk = { @params['state'] => ' selected="selected"' }
3
+ _buf << %Q`<select name="state">
4
+ <option value="">-</option>
5
+ <option value="CA"#{chk["CA"]}>California</option>
6
+ <option value="FL"#{chk["FL"]}>Florida</option>
7
+ <option value="HI"#{chk["HI"]}>Hawaii</option>
8
+ <option value="NY"#{chk["NY"]}>New York</option>
9
+ <option value="TX"#{chk["TX"]}>Texas</option>
10
+ </select>\n`
@@ -0,0 +1,6 @@
1
+ <?RB require 'cgi' ?>
2
+ <?RB ## ex. link_to('Show', '/show/1') => <a href="/show/1">Show</a> ?>
3
+ <?RB def link_to(label, url) ?>
4
+ <?RB return "<a href=\"#{CGI.unescape(url)}\">#{label}</a>" ?>
5
+ <?RB end ?>
6
+ #{{link_to 'Show '+_P('@params["name"]'), '/items/show/'+_p('@params["id"]')}}
@@ -0,0 +1,2 @@
1
+ $ rbtenjin -P example13.rbhtml
2
+ <a href="/items/show/#{@params["id"]}">Show ${@params["name"]}</a>
@@ -0,0 +1,2 @@
1
+ $ rbtenjin --preprocess -sb example13.rbhtml
2
+ _buf << %Q`<a href="/items/show/#{@params["id"]}">Show #{escape((@params["name"]).to_s)}</a>\n`
@@ -0,0 +1,32 @@
1
+ ## template file
2
+ filename = 'example14.rbhtml'
3
+
4
+ ## convert into ruby code
5
+ require 'tenjin'
6
+ template = Tenjin::Template.new(filename)
7
+ ## or
8
+ # template = Tenjin::Template.new()
9
+ # script = template.convert_file(filename)
10
+ ## or
11
+ # template = Tenjin::Template.new()
12
+ # input = File.read(filename)
13
+ # script = template.convert(input, filename) # filename is optional
14
+
15
+ ## show converted ruby code
16
+ puts "---- ruby code ----"
17
+ puts template.script
18
+
19
+ ## evaluate ruby code
20
+ hash = {:title=>'rbTenjin Example', :items=>['<AAA>','B&B','"CCC"']}
21
+ output = template.render(hash)
22
+ puts "---- output ----"
23
+ puts output
24
+ ## or
25
+ #hash = {:title=>'rbTenjin Example', :items=>['<AAA>','B&B','"CCC"']}
26
+ #context = Tenjin::Context.new(hash)
27
+ #output = template.render(context)
28
+ ## or
29
+ # context = Tenjin::Context.new
30
+ # context[:title] = 'rbTenjin Example'
31
+ # context[:items] = ['<AAA>','B&B','"CCC"']
32
+ # output = template.render(context)
@@ -0,0 +1,6 @@
1
+ <h1>#{@title}</h1>
2
+ <ul>
3
+ <?rb for item in @items ?>
4
+ <li>${item}</li>
5
+ <?rb end ?>
6
+ </ul>
@@ -0,0 +1,15 @@
1
+ $ ruby example14.rb
2
+ ---- ruby code ----
3
+ _buf << %Q`<h1>#{@title}</h1>
4
+ <ul>\n`
5
+ for item in @items
6
+ _buf << %Q` <li>#{escape((item).to_s)}</li>\n`
7
+ end
8
+ _buf << %Q`</ul>\n`
9
+ ---- output ----
10
+ <h1>rbTenjin Example</h1>
11
+ <ul>
12
+ <li>&lt;AAA&gt;</li>
13
+ <li>B&amp;B</li>
14
+ <li>&quot;CCC&quot;</li>
15
+ </ul>
@@ -0,0 +1,10 @@
1
+ require 'tenjin'
2
+ filename = 'example14.rbhtml'
3
+ template = Tenjin::Template.new(filename, :escapefunc=>'CGI.escapeHTML')
4
+ print template.script, "\n"
5
+
6
+ require 'cgi'
7
+ title = 'rbTenjin Example'
8
+ items = ['<foo>', '&bar', '"baz"']
9
+ output = template.render(:title=>title, :items=>items)
10
+ print output
@@ -0,0 +1,14 @@
1
+ $ ruby example15.rb
2
+ _buf << %Q`<h1>#{@title}</h1>
3
+ <ul>\n`
4
+ for item in @items
5
+ _buf << %Q` <li>#{CGI.escapeHTML((item).to_s)}</li>\n`
6
+ end
7
+ _buf << %Q`</ul>\n`
8
+
9
+ <h1>rbTenjin Example</h1>
10
+ <ul>
11
+ <li>&lt;foo&gt;</li>
12
+ <li>&amp;bar</li>
13
+ <li>&quot;baz&quot;</li>
14
+ </ul>
@@ -0,0 +1,4 @@
1
+ <?rb #@ARGS label, url ?>
2
+ <ul>
3
+ <li>#{link_to(label, url)}</li>
4
+ </ul>
@@ -0,0 +1,10 @@
1
+ require 'tenjin'
2
+
3
+ def link_to(label, url)
4
+ return "<a href=\"#{escape_xml(url)}\">#{escape_xml(label)}</a>"
5
+ end
6
+
7
+ engine = Tenjin::Engine.new()
8
+ context = { :label=>'Top', :url=>'/' }
9
+ output = engine.render('example16.rbhtml', context)
10
+ print output
@@ -0,0 +1,4 @@
1
+ $ ruby example16a.rb
2
+ <ul>
3
+ <li><a href="/">Top</a></li>
4
+ </ul>
@@ -0,0 +1,13 @@
1
+ require 'tenjin'
2
+
3
+ module Tenjin::ContextHelper
4
+ module_function
5
+ def link_to(label, url)
6
+ return "<a href=\"#{escape_xml(url)}\">#{escape_xml(label)}</a>"
7
+ end
8
+ end
9
+
10
+ engine = Tenjin::Engine.new()
11
+ context = { :label=>'Top', :url=>'/' }
12
+ output = engine.render('example16.rbhtml', context)
13
+ print output
@@ -0,0 +1,4 @@
1
+ $ ruby example16b.rb
2
+ <ul>
3
+ <li><a href="/">Top</a></li>
4
+ </ul>
@@ -0,0 +1,12 @@
1
+ require 'tenjin'
2
+
3
+ class MyContext < Tenjin::Context
4
+ def link_to(label, url)
5
+ return "<a href=\"#{escape_xml(url)}\">#{escape_xml(label)}</a>"
6
+ end
7
+ end
8
+
9
+ engine = Tenjin::Engine.new()
10
+ context = MyContext.new(:label=>'Top', :url=>'/')
11
+ output = engine.render('example16.rbhtml', context)
12
+ print output
@@ -0,0 +1,4 @@
1
+ $ ruby example16c.rb
2
+ <ul>
3
+ <li><a href="/">Top</a></li>
4
+ </ul>
@@ -0,0 +1,14 @@
1
+ $ rbtenjin -S example1.rbhtml
2
+ _buf = '';
3
+
4
+ i = 0
5
+ for item in ['<foo>', 'bar&bar', '"baz"']
6
+ i += 1
7
+
8
+
9
+ escape((item).to_s);
10
+
11
+ end
12
+
13
+
14
+ _buf.to_s
@@ -0,0 +1,10 @@
1
+ $ rbtenjin -SUNX example1.rbhtml
2
+ 1: _buf = '';
3
+
4
+ 3: i = 0
5
+ 4: for item in ['<foo>', 'bar&bar', '"baz"']
6
+ 5: i += 1
7
+
8
+ 10: end
9
+
10
+ 13: _buf.to_s
@@ -0,0 +1,14 @@
1
+ $ rbtenjin -s example1.rbhtml
2
+ _buf = ''; _buf << %Q`<table>
3
+ <tbody>\n`
4
+ i = 0
5
+ for item in ['<foo>', 'bar&bar', '"baz"']
6
+ i += 1
7
+ _buf << %Q` <tr>
8
+ <td>#{item}</td>
9
+ <td>#{escape((item).to_s)}</td>
10
+ </tr>\n`
11
+ end
12
+ _buf << %Q` <tbody>
13
+ </table>\n`
14
+ _buf.to_s
@@ -0,0 +1,3 @@
1
+ <?rb for i in [1, 2, 3] ?>
2
+ <p>#{item}</p>
3
+ <?rb end ?>
@@ -0,0 +1,9 @@
1
+ $ rbtenjin -s example2.rbhtml
2
+ _buf = ''; for i in [1, 2, 3]
3
+ _buf << %Q`<p>#{item}</p>\n`
4
+ end
5
+ _buf.to_s
6
+ $ rbtenjin -sb example2.rbhtml
7
+ for i in [1, 2, 3]
8
+ _buf << %Q`<p>#{item}</p>\n`
9
+ end
@@ -0,0 +1,5 @@
1
+ <ul>
2
+ <?rb for item in items ?>
3
+ <li>${item}</li>
4
+ <?rb ende ?>
5
+ </ul>
@@ -0,0 +1,2 @@
1
+ $ rbtenjin -wz example3.rbhtml
2
+ example3.rbhtml:5: syntax error, unexpected $end, expecting kEND
@@ -0,0 +1,13 @@
1
+ <p>
2
+ ${@text}
3
+ #{@num}
4
+ #{@flag}
5
+ </p>
6
+
7
+ <?rb for item in @items ?>
8
+ <p>${item}</p>
9
+ <?rb end ?>
10
+
11
+ <?rb for key, value in @hash ?>
12
+ <p>#{key} = ${value}</p>
13
+ <?rb end ?>
@@ -0,0 +1,13 @@
1
+ $ rbtenjin -f datafile.rb example4.rbhtml
2
+ <p>
3
+ foo
4
+ 3.14
5
+ true
6
+ </p>
7
+
8
+ <p>foo</p>
9
+ <p>bar</p>
10
+ <p>baz</p>
11
+
12
+ <p>x = 1</p>
13
+ <p>y = 2</p>
@@ -0,0 +1,13 @@
1
+ $ rbtenjin -f datafile.yaml example4.rbhtml
2
+ <p>
3
+ foo
4
+ 3.14
5
+ true
6
+ </p>
7
+
8
+ <p>foo</p>
9
+ <p>bar</p>
10
+ <p>baz</p>
11
+
12
+ <p>x = 1</p>
13
+ <p>y = 2</p>
@@ -0,0 +1,9 @@
1
+ text: #{@text}
2
+ items:
3
+ <?rb for item in @items ?>
4
+ - #{item}
5
+ <?rb end ?>
6
+ hash:
7
+ <?rb for key, val in @hash ?>
8
+ #{key}: #{val}
9
+ <?rb end ?>
@@ -0,0 +1,9 @@
1
+ $ rbtenjin -c '@text="foo"; @items=%w[a b c]; @hash={"x"=>1,"y"=>2}' example5.rbhtml
2
+ text: foo
3
+ items:
4
+ - a
5
+ - b
6
+ - c
7
+ hash:
8
+ x: 1
9
+ y: 2
@@ -0,0 +1,9 @@
1
+ $ rbtenjin -c '{text: foo, items: [a, b, c], hash: {x: 1, y: 2} }' example5.rbhtml
2
+ text: foo
3
+ items:
4
+ - a
5
+ - b
6
+ - c
7
+ hash:
8
+ x: 1
9
+ y: 2