tenjin 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (282) hide show
  1. data/CHANGES.txt +163 -0
  2. data/MIT-LICENSE +16 -17
  3. data/README.txt +5 -5
  4. data/benchmark/Makefile +9 -0
  5. data/benchmark/bench.rb +3 -2
  6. data/bin/rbtenjin +6 -3
  7. data/doc/docstyle.css +25 -4
  8. data/doc/users-guide.html +2088 -1563
  9. data/lib/tenjin.rb +784 -158
  10. data/public_html/_layout.rbhtml +33 -0
  11. data/public_html/css/style.css +77 -0
  12. data/public_html/env.rbhtml +15 -0
  13. data/public_html/favicon.ico +0 -0
  14. data/public_html/hello.rbhtml +14 -0
  15. data/public_html/index.rbhtml +39 -0
  16. data/public_html/rbtenjin.cgi +188 -0
  17. data/tenjin.gemspec +9 -6
  18. data/test/data/examples/preprocessing/main.rb +1 -1
  19. data/test/data/examples/preprocessing/select.rbhtml +1 -1
  20. data/test/data/faq/{ex11-bench.rb → ex10-bench.rb} +3 -3
  21. data/test/data/faq/ex10-content.rbhtml +8 -11
  22. data/test/data/faq/{ex11-layout1.rbhtml → ex10-layout1.rbhtml} +0 -0
  23. data/test/data/faq/{ex11-layout2.rbhtml → ex10-layout2.rbhtml} +0 -0
  24. data/test/data/faq/{ex11.rb → ex10.rb} +1 -1
  25. data/test/data/faq/{ex11.rbhtml → ex10.rbhtml} +0 -0
  26. data/test/data/faq/{ex11.source → ex10.source} +2 -2
  27. data/test/data/faq/{ex11_arraybuffer.result → ex10_arraybuffer.result} +1 -1
  28. data/test/data/faq/{ex5.rbhtml → ex2.rbhtml} +0 -0
  29. data/test/data/faq/{ex5_template_args.source → ex2_template_args.source} +1 -1
  30. data/test/data/faq/{ex7-expr-pattern.rb → ex4-expr-pattern.rb} +1 -1
  31. data/test/data/faq/{ex7-expr-pattern.rbhtml → ex4-expr-pattern.rbhtml} +0 -0
  32. data/test/data/faq/{ex7_expr_pattern.result → ex4_expr_pattern.result} +1 -1
  33. data/test/data/faq/{ex6-content.rhtml → ex5-content.rhtml} +0 -0
  34. data/test/data/faq/{ex6-layout.rhtml → ex5-layout.rhtml} +0 -0
  35. data/test/data/faq/{ex6.rb → ex5.rb} +2 -2
  36. data/test/data/faq/{ex6_eruby.result → ex5_eruby.result} +1 -1
  37. data/test/data/faq/{ex2-content.rbhtml → ex6-content.rbhtml} +0 -0
  38. data/test/data/faq/{ex2-layout.rbhtml → ex6-layout.rbhtml} +0 -0
  39. data/test/data/faq/{ex2_removenl.result → ex6_removenl.result} +1 -1
  40. data/test/data/faq/ex7-m18n.rb +48 -0
  41. data/test/data/faq/{ex8-m18n.rbhtml → ex7-m18n.rbhtml} +0 -0
  42. data/test/data/faq/{ex8_m18n.result → ex7_m18n.result} +1 -1
  43. data/test/data/faq/ex8-baselayout.rbhtml +8 -0
  44. data/test/data/faq/ex8-content.rbhtml +6 -0
  45. data/test/data/faq/{ex9-mylayout.rbhtml → ex8-mylayout.rbhtml} +0 -0
  46. data/test/data/faq/{ex9_changelayout.result → ex8_changelayout.result} +1 -1
  47. data/test/data/faq/ex9-baselayout.rbhtml +24 -5
  48. data/test/data/faq/ex9-content.rbhtml +12 -6
  49. data/test/data/faq/{ex10-customlayout.rbhtml → ex9-customlayout.rbhtml} +1 -1
  50. data/test/data/faq/{ex10_inherit.result → ex9_inherit.result} +1 -1
  51. data/test/data/faq/helpers1.rb +17 -0
  52. data/test/data/faq/helpers1.rbhtml +4 -0
  53. data/test/data/faq/helpers1.result +11 -0
  54. data/test/data/faq/helpers2.rb +21 -0
  55. data/test/data/faq/helpers2.rbhtml +4 -0
  56. data/test/data/faq/helpers2.result +11 -0
  57. data/test/data/faq/weekday1.rb +6 -0
  58. data/test/data/faq/weekday1.rbhtml +9 -0
  59. data/test/data/faq/weekday1.result +23 -0
  60. data/test/data/faq/weekday2.rb +8 -0
  61. data/test/data/faq/weekday2.rbhtml +10 -0
  62. data/test/data/faq/weekday2.result +24 -0
  63. data/test/data/faq/weekday3.rb +22 -0
  64. data/test/data/faq/weekday3.rbhtml +3 -0
  65. data/test/data/faq/weekday3.result +28 -0
  66. data/test/data/users_guide/test_010/main.rb +14 -0
  67. data/test/data/users_guide/test_010/result.output +13 -0
  68. data/test/data/users_guide/test_010/views/page.rbhtml +11 -0
  69. data/test/data/users_guide/test_011/main.rb +14 -0
  70. data/test/data/users_guide/test_011/result.output +2 -0
  71. data/test/data/users_guide/test_011/views/page.rbhtml +11 -0
  72. data/test/data/users_guide/test_020/main.rb +14 -0
  73. data/test/data/users_guide/test_020/result.output +13 -0
  74. data/test/data/users_guide/test_020/views/page.rbhtml +11 -0
  75. data/test/data/users_guide/test_021/main.rb +12 -0
  76. data/test/data/users_guide/test_021/result.output +12 -0
  77. data/test/data/users_guide/test_021/views/page.rbhtml +11 -0
  78. data/test/data/users_guide/test_030/main.rb +14 -0
  79. data/test/data/users_guide/test_030/result.output +23 -0
  80. data/test/data/users_guide/test_030/views/_layout.rbhtml +10 -0
  81. data/test/data/users_guide/test_030/views/page.rbhtml +11 -0
  82. data/test/data/users_guide/test_040/main.rb +14 -0
  83. data/test/data/users_guide/test_040/result.output +23 -0
  84. data/test/data/users_guide/test_040/views/_layout.rbhtml +10 -0
  85. data/test/data/users_guide/test_040/views/page.rbhtml +12 -0
  86. data/test/data/users_guide/test_050/main.rb +14 -0
  87. data/test/data/users_guide/test_050/result.output +14 -0
  88. data/test/data/users_guide/test_050/views/_layout.rbhtml +10 -0
  89. data/test/data/users_guide/test_050/views/page.rbhtml +13 -0
  90. data/test/data/users_guide/test_051/main.rb +14 -0
  91. data/test/data/users_guide/test_051/result.output +12 -0
  92. data/test/data/users_guide/test_051/views/_layout.rbhtml +11 -0
  93. data/test/data/users_guide/test_051/views/page.rbhtml +13 -0
  94. data/test/data/users_guide/test_060/main.rb +14 -0
  95. data/test/data/users_guide/test_060/result.output +29 -0
  96. data/test/data/users_guide/test_060/views/_footer.rbhtml +3 -0
  97. data/test/data/users_guide/test_060/views/_header.rbhtml +3 -0
  98. data/test/data/users_guide/test_060/views/_layout.rbhtml +13 -0
  99. data/test/data/users_guide/test_060/views/page.rbhtml +13 -0
  100. data/test/data/users_guide/test_070/main.rb +14 -0
  101. data/test/data/users_guide/test_070/result.output +29 -0
  102. data/test/data/users_guide/test_070/views/_footer.rbhtml +3 -0
  103. data/test/data/users_guide/test_070/views/_header.rbhtml +3 -0
  104. data/test/data/users_guide/test_070/views/_layout.rbhtml +13 -0
  105. data/test/data/users_guide/test_070/views/page.rbhtml +13 -0
  106. data/test/data/users_guide/test_capturing/main.rb +24 -0
  107. data/test/data/users_guide/test_capturing/result.output +28 -0
  108. data/test/data/users_guide/test_capturing/views/_layout.rbhtml +21 -0
  109. data/test/data/users_guide/test_capturing/views/blog-post.rbhtml +13 -0
  110. data/test/data/users_guide/test_context/context.rb +5 -0
  111. data/test/data/users_guide/test_context/context.yaml +4 -0
  112. data/test/data/users_guide/test_context/example.rbhtml +5 -0
  113. data/test/data/users_guide/test_context/result1.output +6 -0
  114. data/test/data/users_guide/test_context/result2.output +6 -0
  115. data/test/data/users_guide/test_context/result3.output +6 -0
  116. data/test/data/users_guide/test_context/result4.output +6 -0
  117. data/test/data/users_guide/test_convert/example.rbhtml +5 -0
  118. data/test/data/users_guide/test_convert/result1.output +7 -0
  119. data/test/data/users_guide/test_convert/result2.output +6 -0
  120. data/test/data/users_guide/test_escape/main.rb +4 -0
  121. data/test/data/users_guide/test_escape/result.output +5 -0
  122. data/test/data/users_guide/test_escape/views/page.rbhtml +4 -0
  123. data/test/data/users_guide/test_execute/example.rbhtml +6 -0
  124. data/test/data/users_guide/test_execute/result.output +6 -0
  125. data/test/data/users_guide/test_fragmentcache/cache.d/items/1 +5 -0
  126. data/test/data/users_guide/test_fragmentcache/main.rb +21 -0
  127. data/test/data/users_guide/test_fragmentcache/result.output +8 -0
  128. data/test/data/users_guide/test_fragmentcache/result2.output +6 -0
  129. data/test/data/users_guide/test_fragmentcache/views/items.rbhtml +10 -0
  130. data/test/data/users_guide/test_logging/ex-logger.rb +11 -0
  131. data/test/data/users_guide/test_logging/example.rbhtml +0 -0
  132. data/test/data/users_guide/test_logging/result1.output +3 -0
  133. data/test/data/users_guide/test_logging/result2.output +2 -0
  134. data/test/data/users_guide/test_m17n/m17n.rb +44 -0
  135. data/test/data/users_guide/test_m17n/m17n.rbhtml +5 -0
  136. data/test/data/users_guide/test_m17n/result.output +9 -0
  137. data/test/data/users_guide/test_m17n/result_en.output +4 -0
  138. data/test/data/users_guide/test_m17n/result_fr.output +4 -0
  139. data/test/data/users_guide/test_nested/main.rb +8 -0
  140. data/test/data/users_guide/test_nested/result.output +15 -0
  141. data/test/data/users_guide/test_nested/views/_blog_layout.rbhtml +5 -0
  142. data/test/data/users_guide/{layout8_html.rbhtml → test_nested/views/_site_layout.rbhtml} +0 -0
  143. data/test/data/users_guide/test_nested/views/blog_post.rbhtml +4 -0
  144. data/test/data/users_guide/test_preprocessing/pp-example1.rb +14 -0
  145. data/test/data/users_guide/test_preprocessing/result1a.output +11 -0
  146. data/test/data/users_guide/test_preprocessing/result1b.output +5 -0
  147. data/test/data/users_guide/test_preprocessing/result1c.output +6 -0
  148. data/test/data/users_guide/test_preprocessing/result2a.output +10 -0
  149. data/test/data/users_guide/test_preprocessing/result2b.output +10 -0
  150. data/test/data/users_guide/test_preprocessing/result3a.output +2 -0
  151. data/test/data/users_guide/test_preprocessing/result3b.output +2 -0
  152. data/test/data/users_guide/test_preprocessing/views/pp-example1.rbhtml +4 -0
  153. data/test/data/users_guide/{example12.rbhtml → test_preprocessing/views/pp-example2.rbhtml} +4 -4
  154. data/test/data/users_guide/test_preprocessing/views/pp-example3.rbhtml +7 -0
  155. data/test/data/users_guide/test_retrieve/example.rbhtml +10 -0
  156. data/test/data/users_guide/test_retrieve/result1.output +11 -0
  157. data/test/data/users_guide/test_retrieve/result2.output +11 -0
  158. data/test/data/users_guide/test_retrieve/result3.output +11 -0
  159. data/test/data/users_guide/test_retrieve/result4.output +8 -0
  160. data/test/data/users_guide/test_retrieve/result5.output +5 -0
  161. data/test/data/users_guide/test_safe/result.output +6 -0
  162. data/test/data/users_guide/test_safe/safe-test.rb +21 -0
  163. data/test/data/users_guide/test_safehelper/main.rb +16 -0
  164. data/test/data/users_guide/test_safehelper/result.output +8 -0
  165. data/test/data/users_guide/{example3.rbhtml → test_syntax_check/example.rbhtml} +0 -0
  166. data/test/data/users_guide/test_syntax_check/result.output +2 -0
  167. data/test/data/users_guide/test_trace/layout.rbhtml +7 -0
  168. data/test/data/users_guide/test_trace/main.rbhtml +5 -0
  169. data/test/data/users_guide/test_trace/result.output +16 -0
  170. data/test/data/users_guide/test_trace/trace-example.rb +4 -0
  171. data/test/oktest.rb +755 -0
  172. data/test/test_all.rb +24 -14
  173. data/test/test_engine.rb +628 -63
  174. data/test/test_engine.yaml +40 -3
  175. data/test/test_examples.rb +14 -12
  176. data/test/test_faq.rb +17 -12
  177. data/test/test_htmlhelper.rb +104 -33
  178. data/test/test_main.rb +32 -21
  179. data/test/test_main.yaml +2 -2
  180. data/test/test_safe.rb +206 -0
  181. data/test/test_store.rb +220 -0
  182. data/test/test_tcache.rb +94 -0
  183. data/test/test_template.rb +65 -23
  184. data/test/test_template.yaml +7 -7
  185. data/test/test_users_guide.rb +75 -29
  186. data/test/testcase-helper.rb +20 -18
  187. data/test/testunit-assertions.rb +71 -0
  188. metadata +185 -159
  189. data/doc-api/classes/Tenjin.html +0 -141
  190. data/doc-api/classes/Tenjin/ArrayBufferTemplate.html +0 -270
  191. data/doc-api/classes/Tenjin/BaseContext.html +0 -329
  192. data/doc-api/classes/Tenjin/Context.html +0 -126
  193. data/doc-api/classes/Tenjin/ContextHelper.html +0 -461
  194. data/doc-api/classes/Tenjin/Engine.html +0 -616
  195. data/doc-api/classes/Tenjin/ErubisTemplate.html +0 -166
  196. data/doc-api/classes/Tenjin/HtmlHelper.html +0 -359
  197. data/doc-api/classes/Tenjin/Preprocessor.html +0 -242
  198. data/doc-api/classes/Tenjin/Template.html +0 -916
  199. data/doc-api/created.rid +0 -1
  200. data/doc-api/files/README_txt.html +0 -188
  201. data/doc-api/files/lib/tenjin_rb.html +0 -136
  202. data/doc-api/fr_class_index.html +0 -36
  203. data/doc-api/fr_file_index.html +0 -28
  204. data/doc-api/fr_method_index.html +0 -91
  205. data/doc-api/index.html +0 -24
  206. data/doc-api/rdoc-style.css +0 -208
  207. data/doc/examples.html +0 -312
  208. data/doc/faq.html +0 -909
  209. data/examples/preprocessing/select.rbhtml.cache +0 -17
  210. data/test/Rookbook.yaml +0 -14
  211. data/test/assert-text-equal.rb +0 -45
  212. data/test/data/faq/ex10-baselayout.rbhtml +0 -27
  213. data/test/data/faq/ex11-content.rbhtml +0 -9
  214. data/test/data/faq/ex8-m18n.rb +0 -77
  215. data/test/data/users_guide/content6.rbhtml +0 -3
  216. data/test/data/users_guide/content7.rbhtml +0 -5
  217. data/test/data/users_guide/content8.rbhtml +0 -2
  218. data/test/data/users_guide/contextdata.rb +0 -7
  219. data/test/data/users_guide/datafile.rb +0 -5
  220. data/test/data/users_guide/datafile.yaml +0 -10
  221. data/test/data/users_guide/ex.rbhtml +0 -6
  222. data/test/data/users_guide/ex.result +0 -7
  223. data/test/data/users_guide/ex.script +0 -5
  224. data/test/data/users_guide/ex_script.result +0 -7
  225. data/test/data/users_guide/ex_source.result +0 -8
  226. data/test/data/users_guide/example1.rbhtml +0 -12
  227. data/test/data/users_guide/example1.result +0 -17
  228. data/test/data/users_guide/example10.rbhtml +0 -4
  229. data/test/data/users_guide/example10_template_args.result +0 -6
  230. data/test/data/users_guide/example11.rbhtml +0 -5
  231. data/test/data/users_guide/example11_template_args_result +0 -2
  232. data/test/data/users_guide/example12_preprocessed.result +0 -10
  233. data/test/data/users_guide/example12_preprocessed_source.result +0 -10
  234. data/test/data/users_guide/example13.rbhtml +0 -6
  235. data/test/data/users_guide/example13_preprocessed.result +0 -2
  236. data/test/data/users_guide/example13_preprocessed_source.result +0 -2
  237. data/test/data/users_guide/example14.rb +0 -32
  238. data/test/data/users_guide/example14.rbhtml +0 -6
  239. data/test/data/users_guide/example14_tmplclass.result +0 -15
  240. data/test/data/users_guide/example15.rb +0 -10
  241. data/test/data/users_guide/example15_escapefunc.result +0 -14
  242. data/test/data/users_guide/example16.rbhtml +0 -4
  243. data/test/data/users_guide/example16a.rb +0 -10
  244. data/test/data/users_guide/example16a.result +0 -4
  245. data/test/data/users_guide/example16b.rb +0 -13
  246. data/test/data/users_guide/example16b.result +0 -4
  247. data/test/data/users_guide/example16c.rb +0 -12
  248. data/test/data/users_guide/example16c.result +0 -4
  249. data/test/data/users_guide/example16d.rb +0 -27
  250. data/test/data/users_guide/example16d.result +0 -4
  251. data/test/data/users_guide/example1_S.result +0 -14
  252. data/test/data/users_guide/example1_SXNC.result +0 -10
  253. data/test/data/users_guide/example1_source.result +0 -14
  254. data/test/data/users_guide/example2.rbhtml +0 -3
  255. data/test/data/users_guide/example2_sb.result2 +0 -9
  256. data/test/data/users_guide/example3_syntaxcheck.result +0 -2
  257. data/test/data/users_guide/example4.rbhtml +0 -13
  258. data/test/data/users_guide/example4_datafile_rb.result +0 -13
  259. data/test/data/users_guide/example4_yaml.result +0 -13
  260. data/test/data/users_guide/example5.rbhtml +0 -9
  261. data/test/data/users_guide/example5_datastr_rb.result +0 -9
  262. data/test/data/users_guide/example5_datastr_yaml.result +0 -9
  263. data/test/data/users_guide/example6.rbhtml +0 -19
  264. data/test/data/users_guide/example6_layout.result +0 -29
  265. data/test/data/users_guide/example6_nested.result +0 -28
  266. data/test/data/users_guide/example7_layout2.result +0 -13
  267. data/test/data/users_guide/example8_layout3.result +0 -8
  268. data/test/data/users_guide/example9.rbhtml +0 -18
  269. data/test/data/users_guide/example9_capture.result +0 -26
  270. data/test/data/users_guide/footer.html +0 -5
  271. data/test/data/users_guide/footer.rbhtml +0 -4
  272. data/test/data/users_guide/layout6.rbhtml +0 -17
  273. data/test/data/users_guide/layout7.rbhtml +0 -9
  274. data/test/data/users_guide/layout8_xhtml.rbhtml +0 -6
  275. data/test/data/users_guide/layout9.rbhtml +0 -25
  276. data/test/data/users_guide/sidemenu.rbhtml +0 -5
  277. data/test/data/users_guide/user_app.cgi +0 -39
  278. data/test/data/users_guide/user_app.result +0 -30
  279. data/test/data/users_guide/user_create.rbhtml +0 -6
  280. data/test/data/users_guide/user_edit.rbhtml +0 -7
  281. data/test/data/users_guide/user_form.rbhtml +0 -10
  282. data/test/data/users_guide/user_layout.rbhtml +0 -16
@@ -1,616 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Class: Tenjin::Engine</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Class</strong></td>
53
- <td class="class-name-in-header">Tenjin::Engine</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../files/lib/tenjin_rb.html">
59
- lib/tenjin.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- <tr class="top-aligned-row">
66
- <td><strong>Parent:</strong></td>
67
- <td>
68
- Object
69
- </td>
70
- </tr>
71
- </table>
72
- </div>
73
- <!-- banner header -->
74
-
75
- <div id="bodyContent">
76
-
77
-
78
-
79
- <div id="contextContent">
80
-
81
- <div id="description">
82
- <p>
83
- engine class for templates
84
- </p>
85
- <p>
86
- <a href="Engine.html">Engine</a> class supports the followings.
87
- </p>
88
- <ul>
89
- <li>template caching
90
-
91
- </li>
92
- <li>partial template
93
-
94
- </li>
95
- <li>layout template
96
-
97
- </li>
98
- <li>capturing (experimental)
99
-
100
- </li>
101
- </ul>
102
- <p>
103
- ex. file &#8216;ex_list.rbhtml&#8216;
104
- </p>
105
- <pre>
106
- &lt;ul&gt;
107
- &lt;?rb for item in @items ?&gt;
108
- &lt;li&gt;#{item}&lt;/li&gt;
109
- &lt;?rb end ?&gt;
110
- &lt;/ul&gt;
111
- </pre>
112
- <p>
113
- ex. file &#8216;ex_layout.rbhtml&#8216;
114
- </p>
115
- <pre>
116
- &lt;html&gt;
117
- &lt;body&gt;
118
- &lt;h1&gt;${@title}&lt;/li&gt;
119
- #{@_content}
120
- &lt;?rb import 'footer.rbhtml' ?&gt;
121
- &lt;/body&gt;
122
- &lt;/html&gt;
123
- </pre>
124
- <p>
125
- ex. file &#8216;main.rb&#8216;
126
- </p>
127
- <pre>
128
- require 'tenjin'
129
- options = {:prefix=&gt;'ex_', :postfix=&gt;'.rbhtml', :layout=&gt;'ex_layout.rbhtml'}
130
- engine = Tenjin::Engine.new(options)
131
- context = {:title=&gt;'Tenjin Example', :items=&gt;['foo', 'bar', 'baz']}
132
- output = engine.render(:list, context) # or 'ex_list.rbhtml'
133
- print output
134
- </pre>
135
-
136
- </div>
137
-
138
-
139
- </div>
140
-
141
- <div id="method-list">
142
- <h3 class="section-bar">Methods</h3>
143
-
144
- <div class="name-list">
145
- <a href="#M000036">cachename</a>&nbsp;&nbsp;
146
- <a href="#M000037">create_template</a>&nbsp;&nbsp;
147
- <a href="#M000033">find_template_file</a>&nbsp;&nbsp;
148
- <a href="#M000040">get_template</a>&nbsp;&nbsp;
149
- <a href="#M000042">hook_context</a>&nbsp;&nbsp;
150
- <a href="#M000039">load_cachefile</a>&nbsp;&nbsp;
151
- <a href="#M000031">new</a>&nbsp;&nbsp;
152
- <a href="#M000034">read_template_file</a>&nbsp;&nbsp;
153
- <a href="#M000035">register_template</a>&nbsp;&nbsp;
154
- <a href="#M000041">render</a>&nbsp;&nbsp;
155
- <a href="#M000038">store_cachefile</a>&nbsp;&nbsp;
156
- <a href="#M000032">to_filename</a>&nbsp;&nbsp;
157
- </div>
158
- </div>
159
-
160
- </div>
161
-
162
-
163
- <!-- if includes -->
164
-
165
- <div id="section">
166
-
167
-
168
-
169
-
170
-
171
-
172
-
173
-
174
- <!-- if method_list -->
175
- <div id="methods">
176
- <h3 class="section-bar">Public Class methods</h3>
177
-
178
- <div id="method-M000031" class="method-detail">
179
- <a name="M000031"></a>
180
-
181
- <div class="method-heading">
182
- <a href="#M000031" class="method-signature">
183
- <span class="method-name">new</span><span class="method-args">(options={})</span>
184
- </a>
185
- </div>
186
-
187
- <div class="method-description">
188
- <p>
189
- initializer of <a href="Engine.html">Engine</a> class.
190
- </p>
191
- <p>
192
- options:
193
- </p>
194
- <table>
195
- <tr><td valign="top">:prefix :</td><td>prefix string for template name (ex. &#8216;template/&#8217;)
196
-
197
- </td></tr>
198
- <tr><td valign="top">:postfix :</td><td>postfix string for template name (ex. &#8217;.rbhtml&#8217;)
199
-
200
- </td></tr>
201
- <tr><td valign="top">:layout :</td><td>layout template name (default nil)
202
-
203
- </td></tr>
204
- <tr><td valign="top">:path :</td><td>array of directory name (default nil)
205
-
206
- </td></tr>
207
- <tr><td valign="top">:cache :</td><td>save converted ruby code into file or not (default true)
208
-
209
- </td></tr>
210
- <tr><td valign="top">:path :</td><td>list of directory (default nil)
211
-
212
- </td></tr>
213
- <tr><td valign="top">:preprocess :</td><td>flag to activate preprocessing (default nil)
214
-
215
- </td></tr>
216
- <tr><td valign="top">:templateclass :</td><td>template class object (default <a
217
- href="Template.html">Tenjin::Template</a>)
218
-
219
- </td></tr>
220
- </table>
221
- <p><a class="source-toggle" href="#"
222
- onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
223
- <div class="method-source-code" id="M000031-source">
224
- <pre>
225
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 822</span>
226
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span>={})
227
- <span class="ruby-ivar">@prefix</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:prefix</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">''</span>
228
- <span class="ruby-ivar">@postfix</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:postfix</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">''</span>
229
- <span class="ruby-ivar">@layout</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:layout</span>]
230
- <span class="ruby-ivar">@cache</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-identifier">:cache</span>, <span class="ruby-keyword kw">true</span>)
231
- <span class="ruby-ivar">@path</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:path</span>]
232
- <span class="ruby-ivar">@preprocess</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-identifier">:preprocess</span>, <span class="ruby-keyword kw">nil</span>)
233
- <span class="ruby-ivar">@templateclass</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-identifier">:templateclass</span>, <span class="ruby-constant">Template</span>)
234
- <span class="ruby-ivar">@init_opts_for_template</span> = <span class="ruby-identifier">options</span>
235
- <span class="ruby-ivar">@templates</span> = {} <span class="ruby-comment cmt"># filename-&gt;template</span>
236
- <span class="ruby-keyword kw">end</span>
237
- </pre>
238
- </div>
239
- </div>
240
- </div>
241
-
242
- <h3 class="section-bar">Public Instance methods</h3>
243
-
244
- <div id="method-M000036" class="method-detail">
245
- <a name="M000036"></a>
246
-
247
- <div class="method-heading">
248
- <a href="#M000036" class="method-signature">
249
- <span class="method-name">cachename</span><span class="method-args">(filename)</span>
250
- </a>
251
- </div>
252
-
253
- <div class="method-description">
254
- <p><a class="source-toggle" href="#"
255
- onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
256
- <div class="method-source-code" id="M000036-source">
257
- <pre>
258
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 871</span>
259
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cachename</span>(<span class="ruby-identifier">filename</span>)
260
- <span class="ruby-keyword kw">return</span> (<span class="ruby-identifier">filename</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'.cache'</span>).<span class="ruby-identifier">untaint</span>
261
- <span class="ruby-keyword kw">end</span>
262
- </pre>
263
- </div>
264
- </div>
265
- </div>
266
-
267
- <div id="method-M000037" class="method-detail">
268
- <a name="M000037"></a>
269
-
270
- <div class="method-heading">
271
- <a href="#M000037" class="method-signature">
272
- <span class="method-name">create_template</span><span class="method-args">(filename, _context=nil)</span>
273
- </a>
274
- </div>
275
-
276
- <div class="method-description">
277
- <p>
278
- create template object from file
279
- </p>
280
- <p><a class="source-toggle" href="#"
281
- onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
282
- <div class="method-source-code" id="M000037-source">
283
- <pre>
284
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 876</span>
285
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_template</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">_context</span>=<span class="ruby-keyword kw">nil</span>)
286
- <span class="ruby-identifier">template</span> = <span class="ruby-ivar">@templateclass</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">nil</span>, <span class="ruby-ivar">@init_opts_for_template</span>)
287
- <span class="ruby-identifier">template</span>.<span class="ruby-identifier">timestamp</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>()
288
- <span class="ruby-identifier">cache_filename</span> = <span class="ruby-identifier">cachename</span>(<span class="ruby-identifier">filename</span>)
289
- <span class="ruby-identifier">_context</span> = <span class="ruby-identifier">hook_context</span>(<span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">_context</span>.<span class="ruby-identifier">nil?</span>
290
- <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@cache</span>
291
- <span class="ruby-identifier">input</span> = <span class="ruby-identifier">read_template_file</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">_context</span>)
292
- <span class="ruby-identifier">template</span>.<span class="ruby-identifier">convert</span>(<span class="ruby-identifier">input</span>, <span class="ruby-identifier">filename</span>)
293
- <span class="ruby-keyword kw">elsif</span> <span class="ruby-operator">!</span><span class="ruby-identifier">test</span>(<span class="ruby-value">?f</span>, <span class="ruby-identifier">cache_filename</span>) <span class="ruby-operator">||</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">mtime</span>(<span class="ruby-identifier">cache_filename</span>) <span class="ruby-operator">&lt;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">mtime</span>(<span class="ruby-identifier">filename</span>)
294
- <span class="ruby-comment cmt">#$stderr.puts &quot;*** debug: load original&quot;</span>
295
- <span class="ruby-identifier">input</span> = <span class="ruby-identifier">read_template_file</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">_context</span>)
296
- <span class="ruby-identifier">template</span>.<span class="ruby-identifier">convert</span>(<span class="ruby-identifier">input</span>, <span class="ruby-identifier">filename</span>)
297
- <span class="ruby-identifier">store_cachefile</span>(<span class="ruby-identifier">cache_filename</span>, <span class="ruby-identifier">template</span>)
298
- <span class="ruby-keyword kw">else</span>
299
- <span class="ruby-comment cmt">#$stderr.puts &quot;*** debug: load cache&quot;</span>
300
- <span class="ruby-identifier">template</span>.<span class="ruby-identifier">filename</span> = <span class="ruby-identifier">filename</span>
301
- <span class="ruby-identifier">load_cachefile</span>(<span class="ruby-identifier">cache_filename</span>, <span class="ruby-identifier">template</span>)
302
- <span class="ruby-keyword kw">end</span>
303
- <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">template</span>
304
- <span class="ruby-keyword kw">end</span>
305
- </pre>
306
- </div>
307
- </div>
308
- </div>
309
-
310
- <div id="method-M000033" class="method-detail">
311
- <a name="M000033"></a>
312
-
313
- <div class="method-heading">
314
- <a href="#M000033" class="method-signature">
315
- <span class="method-name">find_template_file</span><span class="method-args">(template_name)</span>
316
- </a>
317
- </div>
318
-
319
- <div class="method-description">
320
- <p>
321
- find template filename
322
- </p>
323
- <p><a class="source-toggle" href="#"
324
- onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
325
- <div class="method-source-code" id="M000033-source">
326
- <pre>
327
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 841</span>
328
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">find_template_file</span>(<span class="ruby-identifier">template_name</span>)
329
- <span class="ruby-identifier">filename</span> = <span class="ruby-identifier">to_filename</span>(<span class="ruby-identifier">template_name</span>)
330
- <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@path</span>
331
- <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">dir</span> <span class="ruby-keyword kw">in</span> <span class="ruby-ivar">@path</span>
332
- <span class="ruby-identifier">filepath</span> = <span class="ruby-node">&quot;#{dir}#{File::SEPARATOR}#{filename}&quot;</span>
333
- <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">filepath</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">test</span>(<span class="ruby-value">?f</span>, <span class="ruby-identifier">filepath</span>.<span class="ruby-identifier">untaint</span>)
334
- <span class="ruby-keyword kw">end</span>
335
- <span class="ruby-keyword kw">else</span>
336
- <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">filename</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">test</span>(<span class="ruby-value">?f</span>, <span class="ruby-identifier">filename</span>.<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">untaint</span>) <span class="ruby-comment cmt"># dup is required for frozen string</span>
337
- <span class="ruby-keyword kw">end</span>
338
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;#{filename} (path=#{@path.inspect})&quot;</span>)
339
- <span class="ruby-keyword kw">end</span>
340
- </pre>
341
- </div>
342
- </div>
343
- </div>
344
-
345
- <div id="method-M000040" class="method-detail">
346
- <a name="M000040"></a>
347
-
348
- <div class="method-heading">
349
- <a href="#M000040" class="method-signature">
350
- <span class="method-name">get_template</span><span class="method-args">(template_name, _context=nil)</span>
351
- </a>
352
- </div>
353
-
354
- <div class="method-description">
355
- <p>
356
- get template object
357
- </p>
358
- <p><a class="source-toggle" href="#"
359
- onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
360
- <div class="method-source-code" id="M000040-source">
361
- <pre>
362
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 918</span>
363
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_template</span>(<span class="ruby-identifier">template_name</span>, <span class="ruby-identifier">_context</span>=<span class="ruby-keyword kw">nil</span>)
364
- <span class="ruby-identifier">template</span> = <span class="ruby-ivar">@templates</span>[<span class="ruby-identifier">template_name</span>]
365
- <span class="ruby-identifier">t</span> = <span class="ruby-identifier">template</span>
366
- <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">t</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">timestamp</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">filename</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">timestamp</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">mtime</span>(<span class="ruby-identifier">t</span>.<span class="ruby-identifier">filename</span>)
367
- <span class="ruby-identifier">filename</span> = <span class="ruby-identifier">find_template_file</span>(<span class="ruby-identifier">template_name</span>)
368
- <span class="ruby-identifier">template</span> = <span class="ruby-identifier">create_template</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">_context</span>) <span class="ruby-comment cmt"># _context is passed only for preprocessor</span>
369
- <span class="ruby-identifier">register_template</span>(<span class="ruby-identifier">template_name</span>, <span class="ruby-identifier">template</span>)
370
- <span class="ruby-keyword kw">end</span>
371
- <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">template</span>
372
- <span class="ruby-keyword kw">end</span>
373
- </pre>
374
- </div>
375
- </div>
376
- </div>
377
-
378
- <div id="method-M000042" class="method-detail">
379
- <a name="M000042"></a>
380
-
381
- <div class="method-heading">
382
- <a href="#M000042" class="method-signature">
383
- <span class="method-name">hook_context</span><span class="method-args">(context)</span>
384
- </a>
385
- </div>
386
-
387
- <div class="method-description">
388
- <p><a class="source-toggle" href="#"
389
- onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
390
- <div class="method-source-code" id="M000042-source">
391
- <pre>
392
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 955</span>
393
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">hook_context</span>(<span class="ruby-identifier">context</span>)
394
- <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">context</span>
395
- <span class="ruby-identifier">context</span> = <span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>
396
- <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">context</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
397
- <span class="ruby-identifier">context</span> = <span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">context</span>)
398
- <span class="ruby-keyword kw">end</span>
399
- <span class="ruby-identifier">context</span>.<span class="ruby-identifier">_engine</span> = <span class="ruby-keyword kw">self</span>
400
- <span class="ruby-identifier">context</span>.<span class="ruby-identifier">_layout</span> = <span class="ruby-keyword kw">nil</span>
401
- <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">context</span>
402
- <span class="ruby-keyword kw">end</span>
403
- </pre>
404
- </div>
405
- </div>
406
- </div>
407
-
408
- <div id="method-M000039" class="method-detail">
409
- <a name="M000039"></a>
410
-
411
- <div class="method-heading">
412
- <a href="#M000039" class="method-signature">
413
- <span class="method-name">load_cachefile</span><span class="method-args">(cache_filename, template)</span>
414
- </a>
415
- </div>
416
-
417
- <div class="method-description">
418
- <p>
419
- load template from cache file
420
- </p>
421
- <p><a class="source-toggle" href="#"
422
- onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
423
- <div class="method-source-code" id="M000039-source">
424
- <pre>
425
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 909</span>
426
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">load_cachefile</span>(<span class="ruby-identifier">cache_filename</span>, <span class="ruby-identifier">template</span>)
427
- <span class="ruby-identifier">s</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">cache_filename</span>)
428
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-regexp re">/\A\#\@ARGS (.*?)\r?\n/</span>, <span class="ruby-value str">''</span>)
429
- <span class="ruby-identifier">template</span>.<span class="ruby-identifier">args</span> = <span class="ruby-identifier">$1</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">','</span>)
430
- <span class="ruby-keyword kw">end</span>
431
- <span class="ruby-identifier">template</span>.<span class="ruby-identifier">script</span> = <span class="ruby-identifier">s</span>
432
- <span class="ruby-keyword kw">end</span>
433
- </pre>
434
- </div>
435
- </div>
436
- </div>
437
-
438
- <div id="method-M000034" class="method-detail">
439
- <a name="M000034"></a>
440
-
441
- <div class="method-heading">
442
- <a href="#M000034" class="method-signature">
443
- <span class="method-name">read_template_file</span><span class="method-args">(filename, _context)</span>
444
- </a>
445
- </div>
446
-
447
- <div class="method-description">
448
- <p>
449
- read template file and preprocess it
450
- </p>
451
- <p><a class="source-toggle" href="#"
452
- onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
453
- <div class="method-source-code" id="M000034-source">
454
- <pre>
455
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 855</span>
456
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read_template_file</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">_context</span>)
457
- <span class="ruby-keyword kw">return</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">filename</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@preprocess</span>
458
- <span class="ruby-identifier">_context</span> <span class="ruby-operator">||=</span> {}
459
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">_context</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">_context</span>.<span class="ruby-identifier">_engine</span>.<span class="ruby-identifier">nil?</span>
460
- <span class="ruby-identifier">_context</span> = <span class="ruby-identifier">hook_context</span>(<span class="ruby-identifier">_context</span>)
461
- <span class="ruby-keyword kw">end</span>
462
- <span class="ruby-identifier">preprocessor</span> = <span class="ruby-constant">Preprocessor</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">filename</span>)
463
- <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">preprocessor</span>.<span class="ruby-identifier">render</span>(<span class="ruby-identifier">_context</span>)
464
- <span class="ruby-keyword kw">end</span>
465
- </pre>
466
- </div>
467
- </div>
468
- </div>
469
-
470
- <div id="method-M000035" class="method-detail">
471
- <a name="M000035"></a>
472
-
473
- <div class="method-heading">
474
- <a href="#M000035" class="method-signature">
475
- <span class="method-name">register_template</span><span class="method-args">(template_name, template)</span>
476
- </a>
477
- </div>
478
-
479
- <div class="method-description">
480
- <p>
481
- register template object
482
- </p>
483
- <p><a class="source-toggle" href="#"
484
- onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
485
- <div class="method-source-code" id="M000035-source">
486
- <pre>
487
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 866</span>
488
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">register_template</span>(<span class="ruby-identifier">template_name</span>, <span class="ruby-identifier">template</span>)
489
- <span class="ruby-comment cmt">#template.timestamp = Time.new unless template.timestamp</span>
490
- <span class="ruby-ivar">@templates</span>[<span class="ruby-identifier">template_name</span>] = <span class="ruby-identifier">template</span>
491
- <span class="ruby-keyword kw">end</span>
492
- </pre>
493
- </div>
494
- </div>
495
- </div>
496
-
497
- <div id="method-M000041" class="method-detail">
498
- <a name="M000041"></a>
499
-
500
- <div class="method-heading">
501
- <a href="#M000041" class="method-signature">
502
- <span class="method-name">render</span><span class="method-args">(template_name, context=Context.new, layout=true)</span>
503
- </a>
504
- </div>
505
-
506
- <div class="method-description">
507
- <p>
508
- get template object and evaluate it with context object. if argument
509
- &#8216;layout&#8217; is true then default layout file (specified at
510
- initializer) is used as layout template, else if false then no layout
511
- template is used. if argument &#8216;layout&#8217; is string, it is
512
- regarded as layout template name.
513
- </p>
514
- <p><a class="source-toggle" href="#"
515
- onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
516
- <div class="method-source-code" id="M000041-source">
517
- <pre>
518
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 934</span>
519
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">render</span>(<span class="ruby-identifier">template_name</span>, <span class="ruby-identifier">context</span>=<span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>, <span class="ruby-identifier">layout</span>=<span class="ruby-keyword kw">true</span>)
520
- <span class="ruby-comment cmt">#context = Context.new(context) if context.is_a?(Hash)</span>
521
- <span class="ruby-identifier">context</span> = <span class="ruby-identifier">hook_context</span>(<span class="ruby-identifier">context</span>)
522
- <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
523
- <span class="ruby-identifier">template</span> = <span class="ruby-identifier">get_template</span>(<span class="ruby-identifier">template_name</span>, <span class="ruby-identifier">context</span>) <span class="ruby-comment cmt"># context is passed only for preprocessor</span>
524
- <span class="ruby-identifier">_buf</span> = <span class="ruby-identifier">context</span>.<span class="ruby-identifier">_buf</span>
525
- <span class="ruby-identifier">output</span> = <span class="ruby-identifier">template</span>.<span class="ruby-identifier">render</span>(<span class="ruby-identifier">context</span>)
526
- <span class="ruby-identifier">context</span>.<span class="ruby-identifier">_buf</span> = <span class="ruby-identifier">_buf</span>
527
- <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">context</span>.<span class="ruby-identifier">_layout</span>.<span class="ruby-identifier">nil?</span>
528
- <span class="ruby-identifier">layout</span> = <span class="ruby-identifier">context</span>.<span class="ruby-identifier">_layout</span>
529
- <span class="ruby-identifier">context</span>.<span class="ruby-identifier">_layout</span> = <span class="ruby-keyword kw">nil</span>
530
- <span class="ruby-keyword kw">end</span>
531
- <span class="ruby-identifier">layout</span> = <span class="ruby-ivar">@layout</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">layout</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">layout</span>.<span class="ruby-identifier">nil?</span>
532
- <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">layout</span>
533
- <span class="ruby-identifier">template_name</span> = <span class="ruby-identifier">layout</span>
534
- <span class="ruby-identifier">layout</span> = <span class="ruby-keyword kw">false</span>
535
- <span class="ruby-identifier">context</span>.<span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-value str">'@_content'</span>, <span class="ruby-identifier">output</span>)
536
- <span class="ruby-keyword kw">end</span>
537
- <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">output</span>
538
- <span class="ruby-keyword kw">end</span>
539
- </pre>
540
- </div>
541
- </div>
542
- </div>
543
-
544
- <div id="method-M000038" class="method-detail">
545
- <a name="M000038"></a>
546
-
547
- <div class="method-heading">
548
- <a href="#M000038" class="method-signature">
549
- <span class="method-name">store_cachefile</span><span class="method-args">(cache_filename, template)</span>
550
- </a>
551
- </div>
552
-
553
- <div class="method-description">
554
- <p>
555
- store template into cache file
556
- </p>
557
- <p><a class="source-toggle" href="#"
558
- onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
559
- <div class="method-source-code" id="M000038-source">
560
- <pre>
561
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 898</span>
562
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">store_cachefile</span>(<span class="ruby-identifier">cache_filename</span>, <span class="ruby-identifier">template</span>)
563
- <span class="ruby-identifier">s</span> = <span class="ruby-identifier">template</span>.<span class="ruby-identifier">script</span>
564
- <span class="ruby-identifier">s</span> = <span class="ruby-node">&quot;\#@ARGS #{template.args.join(',')}\n#{s}&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">template</span>.<span class="ruby-identifier">args</span>
565
- <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">cache_filename</span>, <span class="ruby-value str">'w'</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
566
- <span class="ruby-identifier">f</span>.<span class="ruby-identifier">flock</span>(<span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">LOCK_EX</span>)
567
- <span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">s</span>)
568
- <span class="ruby-comment cmt">#f.lock(FIle::LOCK_UN) # File#close() unlocks automatically</span>
569
- <span class="ruby-keyword kw">end</span>
570
- <span class="ruby-keyword kw">end</span>
571
- </pre>
572
- </div>
573
- </div>
574
- </div>
575
-
576
- <div id="method-M000032" class="method-detail">
577
- <a name="M000032"></a>
578
-
579
- <div class="method-heading">
580
- <a href="#M000032" class="method-signature">
581
- <span class="method-name">to_filename</span><span class="method-args">(template_name)</span>
582
- </a>
583
- </div>
584
-
585
- <div class="method-description">
586
- <p>
587
- convert short name into filename (ex. &#8217;:list&#8217; =&gt;
588
- &#8216;template/list.rb.html&#8217;)
589
- </p>
590
- <p><a class="source-toggle" href="#"
591
- onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
592
- <div class="method-source-code" id="M000032-source">
593
- <pre>
594
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 835</span>
595
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_filename</span>(<span class="ruby-identifier">template_name</span>)
596
- <span class="ruby-identifier">name</span> = <span class="ruby-identifier">template_name</span>
597
- <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Symbol</span>) <span class="ruby-operator">?</span> <span class="ruby-node">&quot;#{@prefix}#{name}#{@postfix}&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">name</span>
598
- <span class="ruby-keyword kw">end</span>
599
- </pre>
600
- </div>
601
- </div>
602
- </div>
603
-
604
-
605
- </div>
606
-
607
-
608
- </div>
609
-
610
-
611
- <div id="validator-badges">
612
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
613
- </div>
614
-
615
- </body>
616
- </html>