tenjin 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/CHANGES.txt +46 -0
  2. data/MIT-LICENSE +1 -1
  3. data/README.txt +7 -7
  4. data/bin/rbtenjin +2 -2
  5. data/doc-api/classes/Tenjin.html +2 -2
  6. data/doc-api/classes/Tenjin/ArrayBufferTemplate.html +28 -28
  7. data/doc-api/classes/Tenjin/BaseContext.html +61 -44
  8. data/doc-api/classes/Tenjin/ContextHelper.html +85 -57
  9. data/doc-api/classes/Tenjin/Engine.html +88 -88
  10. data/doc-api/classes/Tenjin/ErubisTemplate.html +7 -7
  11. data/doc-api/classes/Tenjin/Preprocessor.html +28 -28
  12. data/doc-api/classes/Tenjin/Template.html +142 -142
  13. data/doc-api/created.rid +1 -1
  14. data/doc-api/files/README_txt.html +10 -10
  15. data/doc-api/files/lib/tenjin_rb.html +2 -2
  16. data/doc-api/fr_method_index.html +55 -53
  17. data/doc/examples.html +2 -2
  18. data/doc/faq.html +2 -2
  19. data/doc/users-guide.html +47 -4
  20. data/examples/form/Makefile +5 -0
  21. data/examples/form/Rakefile +7 -0
  22. data/examples/form/create.rbhtml +4 -0
  23. data/examples/form/form.rbhtml +14 -0
  24. data/examples/form/layout.rbhtml +8 -0
  25. data/examples/form/main.rb +9 -0
  26. data/examples/form/update.rbhtml +4 -0
  27. data/examples/preprocessing/Makefile +8 -0
  28. data/examples/preprocessing/Rakefile +11 -0
  29. data/examples/preprocessing/helper.rb +16 -0
  30. data/examples/preprocessing/main.rb +11 -0
  31. data/examples/preprocessing/select.rbhtml +15 -0
  32. data/examples/table/Makefile +5 -0
  33. data/examples/table/Rakefile +7 -0
  34. data/examples/table/table.rb +9 -0
  35. data/examples/table/table.rbhtml +16 -0
  36. data/lib/tenjin.rb +28 -18
  37. data/setup.rb +861 -607
  38. data/tenjin.gemspec +16 -12
  39. data/test/assert-text-equal.rb +2 -2
  40. data/test/data/users_guide/example16d.rb +27 -0
  41. data/test/data/users_guide/example16d.result +4 -0
  42. data/test/test_all.rb +2 -2
  43. data/test/test_engine.rb +2 -2
  44. data/test/test_examples.rb +2 -2
  45. data/test/test_faq.rb +2 -2
  46. data/test/test_htmlhelper.rb +2 -2
  47. data/test/test_main.rb +2 -2
  48. data/test/test_template.rb +2 -2
  49. data/test/test_users_guide.rb +2 -2
  50. data/test/testcase-helper.rb +2 -2
  51. metadata +64 -35
@@ -86,14 +86,15 @@ helper module for <a href="BaseContext.html">BaseContext</a> class
86
86
  <h3 class="section-bar">Methods</h3>
87
87
 
88
88
  <div class="name-list">
89
- <a href="#M000015">_P</a>&nbsp;&nbsp;
90
- <a href="#M000016">_decode_params</a>&nbsp;&nbsp;
91
- <a href="#M000014">_p</a>&nbsp;&nbsp;
92
- <a href="#M000013">captured_as</a>&nbsp;&nbsp;
93
- <a href="#M000010">echo</a>&nbsp;&nbsp;
94
- <a href="#M000009">import</a>&nbsp;&nbsp;
95
- <a href="#M000011">start_capture</a>&nbsp;&nbsp;
96
- <a href="#M000012">stop_capture</a>&nbsp;&nbsp;
89
+ <a href="#M000016">_P</a>&nbsp;&nbsp;
90
+ <a href="#M000017">_decode_params</a>&nbsp;&nbsp;
91
+ <a href="#M000015">_p</a>&nbsp;&nbsp;
92
+ <a href="#M000014">captured_as</a>&nbsp;&nbsp;
93
+ <a href="#M000011">echo</a>&nbsp;&nbsp;
94
+ <a href="#M000009">escape</a>&nbsp;&nbsp;
95
+ <a href="#M000010">import</a>&nbsp;&nbsp;
96
+ <a href="#M000012">start_capture</a>&nbsp;&nbsp;
97
+ <a href="#M000013">stop_capture</a>&nbsp;&nbsp;
97
98
  </div>
98
99
  </div>
99
100
 
@@ -138,11 +139,11 @@ helper module for <a href="BaseContext.html">BaseContext</a> class
138
139
  <div id="methods">
139
140
  <h3 class="section-bar">Public Instance methods</h3>
140
141
 
141
- <div id="method-M000015" class="method-detail">
142
- <a name="M000015"></a>
142
+ <div id="method-M000016" class="method-detail">
143
+ <a name="M000016"></a>
143
144
 
144
145
  <div class="method-heading">
145
- <a href="#M000015" class="method-signature">
146
+ <a href="#M000016" class="method-signature">
146
147
  <span class="method-name">_P</span><span class="method-args">(arg)</span>
147
148
  </a>
148
149
  </div>
@@ -150,14 +151,14 @@ helper module for <a href="BaseContext.html">BaseContext</a> class
150
151
  <div class="method-description">
151
152
  <p>
152
153
  ex. <a
153
- href="ContextHelper.html#M000015">_P</a>(&quot;item[&#8216;name&#8217;]&quot;)
154
+ href="ContextHelper.html#M000016">_P</a>(&quot;item[&#8216;name&#8217;]&quot;)
154
155
  =&gt; ${item[&#8216;name&#8217;]}
155
156
  </p>
156
157
  <p><a class="source-toggle" href="#"
157
- onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
158
- <div class="method-source-code" id="M000015-source">
158
+ onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
159
+ <div class="method-source-code" id="M000016-source">
159
160
  <pre>
160
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 201</span>
161
+ <span class="ruby-comment cmt"># File lib/tenjin.rb, line 206</span>
161
162
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_P</span>(<span class="ruby-identifier">arg</span>)
162
163
  <span class="ruby-keyword kw">return</span> <span class="ruby-node">&quot;&lt;`$#{arg}$`&gt;&quot;</span> <span class="ruby-comment cmt"># decoded into ${...} by preprocessor</span>
163
164
  <span class="ruby-keyword kw">end</span>
@@ -166,11 +167,11 @@ href="ContextHelper.html#M000015">_P</a>(&quot;item[&#8216;name&#8217;]&quot;)
166
167
  </div>
167
168
  </div>
168
169
 
169
- <div id="method-M000016" class="method-detail">
170
- <a name="M000016"></a>
170
+ <div id="method-M000017" class="method-detail">
171
+ <a name="M000017"></a>
171
172
 
172
173
  <div class="method-heading">
173
- <a href="#M000016" class="method-signature">
174
+ <a href="#M000017" class="method-signature">
174
175
  <span class="method-name">_decode_params</span><span class="method-args">(s)</span>
175
176
  </a>
176
177
  </div>
@@ -181,10 +182,10 @@ decode &lt;`#&#8230;#`&gt; and &lt;`$&#8230;$`&gt; into #{&#8230;} and
181
182
  ${&#8230;}
182
183
  </p>
183
184
  <p><a class="source-toggle" href="#"
184
- onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
185
- <div class="method-source-code" id="M000016-source">
185
+ onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
186
+ <div class="method-source-code" id="M000017-source">
186
187
  <pre>
187
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 208</span>
188
+ <span class="ruby-comment cmt"># File lib/tenjin.rb, line 213</span>
188
189
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_decode_params</span>(<span class="ruby-identifier">s</span>)
189
190
  <span class="ruby-identifier">require</span> <span class="ruby-value str">'cgi'</span>
190
191
  <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">s</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
@@ -202,11 +203,11 @@ ${&#8230;}
202
203
  </div>
203
204
  </div>
204
205
 
205
- <div id="method-M000014" class="method-detail">
206
- <a name="M000014"></a>
206
+ <div id="method-M000015" class="method-detail">
207
+ <a name="M000015"></a>
207
208
 
208
209
  <div class="method-heading">
209
- <a href="#M000014" class="method-signature">
210
+ <a href="#M000015" class="method-signature">
210
211
  <span class="method-name">_p</span><span class="method-args">(arg)</span>
211
212
  </a>
212
213
  </div>
@@ -214,14 +215,14 @@ ${&#8230;}
214
215
  <div class="method-description">
215
216
  <p>
216
217
  ex. <a
217
- href="ContextHelper.html#M000014">_p</a>(&quot;item[&#8216;name&#8217;]&quot;)
218
+ href="ContextHelper.html#M000015">_p</a>(&quot;item[&#8216;name&#8217;]&quot;)
218
219
  =&gt; #{item[&#8216;name&#8217;]}
219
220
  </p>
220
221
  <p><a class="source-toggle" href="#"
221
- onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
222
- <div class="method-source-code" id="M000014-source">
222
+ onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
223
+ <div class="method-source-code" id="M000015-source">
223
224
  <pre>
224
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 194</span>
225
+ <span class="ruby-comment cmt"># File lib/tenjin.rb, line 199</span>
225
226
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_p</span>(<span class="ruby-identifier">arg</span>)
226
227
  <span class="ruby-keyword kw">return</span> <span class="ruby-node">&quot;&lt;`\##{arg}\#`&gt;&quot;</span> <span class="ruby-comment cmt"># decoded into #{...} by preprocessor</span>
227
228
  <span class="ruby-keyword kw">end</span>
@@ -230,11 +231,11 @@ href="ContextHelper.html#M000014">_p</a>(&quot;item[&#8216;name&#8217;]&quot;)
230
231
  </div>
231
232
  </div>
232
233
 
233
- <div id="method-M000013" class="method-detail">
234
- <a name="M000013"></a>
234
+ <div id="method-M000014" class="method-detail">
235
+ <a name="M000014"></a>
235
236
 
236
237
  <div class="method-heading">
237
- <a href="#M000013" class="method-signature">
238
+ <a href="#M000014" class="method-signature">
238
239
  <span class="method-name">captured_as</span><span class="method-args">(name)</span>
239
240
  </a>
240
241
  </div>
@@ -245,10 +246,10 @@ if captured string is found then add it to _buf and return true, else
245
246
  return false. this is a helper method for layout template.
246
247
  </p>
247
248
  <p><a class="source-toggle" href="#"
248
- onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
249
- <div class="method-source-code" id="M000013-source">
249
+ onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
250
+ <div class="method-source-code" id="M000014-source">
250
251
  <pre>
251
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 184</span>
252
+ <span class="ruby-comment cmt"># File lib/tenjin.rb, line 189</span>
252
253
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">captured_as</span>(<span class="ruby-identifier">name</span>)
253
254
  <span class="ruby-identifier">str</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-node">&quot;@#{name}&quot;</span>)
254
255
  <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">str</span>
@@ -260,11 +261,11 @@ return false. this is a helper method for layout template.
260
261
  </div>
261
262
  </div>
262
263
 
263
- <div id="method-M000010" class="method-detail">
264
- <a name="M000010"></a>
264
+ <div id="method-M000011" class="method-detail">
265
+ <a name="M000011"></a>
265
266
 
266
267
  <div class="method-heading">
267
- <a href="#M000010" class="method-signature">
268
+ <a href="#M000011" class="method-signature">
268
269
  <span class="method-name">echo</span><span class="method-args">(value)</span>
269
270
  </a>
270
271
  </div>
@@ -274,10 +275,10 @@ return false. this is a helper method for layout template.
274
275
  add value into _buf. this is equivarent to &#8217;#{value}&#8217;.
275
276
  </p>
276
277
  <p><a class="source-toggle" href="#"
277
- onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
278
- <div class="method-source-code" id="M000010-source">
278
+ onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
279
+ <div class="method-source-code" id="M000011-source">
279
280
  <pre>
280
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 116</span>
281
+ <span class="ruby-comment cmt"># File lib/tenjin.rb, line 121</span>
281
282
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">echo</span>(<span class="ruby-identifier">value</span>)
282
283
  <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">_buf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">value</span>
283
284
  <span class="ruby-keyword kw">end</span>
@@ -291,20 +292,47 @@ add value into _buf. this is equivarent to &#8217;#{value}&#8217;.
291
292
 
292
293
  <div class="method-heading">
293
294
  <a href="#M000009" class="method-signature">
294
- <span class="method-name">import</span><span class="method-args">(template_name, _append_to_buf=true)</span>
295
+ <span class="method-name">escape</span><span class="method-args">(val)</span>
295
296
  </a>
296
297
  </div>
297
298
 
298
299
  <div class="method-description">
299
300
  <p>
300
- include template. &#8216;template_name&#8217; can be filename or short
301
- name.
301
+ <a href="ContextHelper.html#M000009">escape</a> value. this method should
302
+ be overrided in subclass.
302
303
  </p>
303
304
  <p><a class="source-toggle" href="#"
304
305
  onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
305
306
  <div class="method-source-code" id="M000009-source">
306
307
  <pre>
307
308
  <span class="ruby-comment cmt"># File lib/tenjin.rb, line 108</span>
309
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">escape</span>(<span class="ruby-identifier">val</span>)
310
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">val</span>
311
+ <span class="ruby-keyword kw">end</span>
312
+ </pre>
313
+ </div>
314
+ </div>
315
+ </div>
316
+
317
+ <div id="method-M000010" class="method-detail">
318
+ <a name="M000010"></a>
319
+
320
+ <div class="method-heading">
321
+ <a href="#M000010" class="method-signature">
322
+ <span class="method-name">import</span><span class="method-args">(template_name, _append_to_buf=true)</span>
323
+ </a>
324
+ </div>
325
+
326
+ <div class="method-description">
327
+ <p>
328
+ include template. &#8216;template_name&#8217; can be filename or short
329
+ name.
330
+ </p>
331
+ <p><a class="source-toggle" href="#"
332
+ onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
333
+ <div class="method-source-code" id="M000010-source">
334
+ <pre>
335
+ <span class="ruby-comment cmt"># File lib/tenjin.rb, line 113</span>
308
336
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">import</span>(<span class="ruby-identifier">template_name</span>, <span class="ruby-identifier">_append_to_buf</span>=<span class="ruby-keyword kw">true</span>)
309
337
  <span class="ruby-identifier">_buf</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">_buf</span>
310
338
  <span class="ruby-identifier">output</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">_engine</span>.<span class="ruby-identifier">render</span>(<span class="ruby-identifier">template_name</span>, <span class="ruby-identifier">context</span>=<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">layout</span>=<span class="ruby-keyword kw">false</span>)
@@ -316,11 +344,11 @@ name.
316
344
  </div>
317
345
  </div>
318
346
 
319
- <div id="method-M000011" class="method-detail">
320
- <a name="M000011"></a>
347
+ <div id="method-M000012" class="method-detail">
348
+ <a name="M000012"></a>
321
349
 
322
350
  <div class="method-heading">
323
- <a href="#M000011" class="method-signature">
351
+ <a href="#M000012" class="method-signature">
324
352
  <span class="method-name">start_capture</span><span class="method-args">(varname=nil) {|| ...}</span>
325
353
  </a>
326
354
  </div>
@@ -329,7 +357,7 @@ name.
329
357
  <p>
330
358
  start capturing. returns captured string if block given, else return nil.
331
359
  if block is not given, calling <a
332
- href="ContextHelper.html#M000012">stop_capture</a>() is required.
360
+ href="ContextHelper.html#M000013">stop_capture</a>() is required.
333
361
  </p>
334
362
  <p>
335
363
  ex. list.rbhtml
@@ -364,10 +392,10 @@ ex. layout.rbhtml
364
392
  &lt;/html&gt;
365
393
  </pre>
366
394
  <p><a class="source-toggle" href="#"
367
- onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
368
- <div class="method-source-code" id="M000011-source">
395
+ onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
396
+ <div class="method-source-code" id="M000012-source">
369
397
  <pre>
370
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 151</span>
398
+ <span class="ruby-comment cmt"># File lib/tenjin.rb, line 156</span>
371
399
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start_capture</span>(<span class="ruby-identifier">varname</span>=<span class="ruby-keyword kw">nil</span>)
372
400
  <span class="ruby-ivar">@_capture_varname</span> = <span class="ruby-identifier">varname</span>
373
401
  <span class="ruby-ivar">@_start_position</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">_buf</span>.<span class="ruby-identifier">length</span>
@@ -384,11 +412,11 @@ ex. layout.rbhtml
384
412
  </div>
385
413
  </div>
386
414
 
387
- <div id="method-M000012" class="method-detail">
388
- <a name="M000012"></a>
415
+ <div id="method-M000013" class="method-detail">
416
+ <a name="M000013"></a>
389
417
 
390
418
  <div class="method-heading">
391
- <a href="#M000012" class="method-signature">
419
+ <a href="#M000013" class="method-signature">
392
420
  <span class="method-name">stop_capture</span><span class="method-args">(store_to_context=true)</span>
393
421
  </a>
394
422
  </div>
@@ -396,13 +424,13 @@ ex. layout.rbhtml
396
424
  <div class="method-description">
397
425
  <p>
398
426
  stop capturing. returns captured string. see <a
399
- href="ContextHelper.html#M000011">start_capture</a>()&#8217;s document.
427
+ href="ContextHelper.html#M000012">start_capture</a>()&#8217;s document.
400
428
  </p>
401
429
  <p><a class="source-toggle" href="#"
402
- onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
403
- <div class="method-source-code" id="M000012-source">
430
+ onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
431
+ <div class="method-source-code" id="M000013-source">
404
432
  <pre>
405
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 168</span>
433
+ <span class="ruby-comment cmt"># File lib/tenjin.rb, line 173</span>
406
434
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stop_capture</span>(<span class="ruby-identifier">store_to_context</span>=<span class="ruby-keyword kw">true</span>)
407
435
  <span class="ruby-identifier">output</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">_buf</span>[<span class="ruby-ivar">@_start_position</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>]
408
436
  <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">_buf</span>[<span class="ruby-ivar">@_start_position</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>] = <span class="ruby-value str">''</span>
@@ -142,18 +142,18 @@ ex. file &#8216;main.rb&#8216;
142
142
  <h3 class="section-bar">Methods</h3>
143
143
 
144
144
  <div class="name-list">
145
- <a href="#M000034">cachename</a>&nbsp;&nbsp;
146
- <a href="#M000035">create_template</a>&nbsp;&nbsp;
147
- <a href="#M000031">find_template_file</a>&nbsp;&nbsp;
148
- <a href="#M000038">get_template</a>&nbsp;&nbsp;
149
- <a href="#M000040">hook_context</a>&nbsp;&nbsp;
150
- <a href="#M000037">load_cachefile</a>&nbsp;&nbsp;
151
- <a href="#M000029">new</a>&nbsp;&nbsp;
152
- <a href="#M000032">read_template_file</a>&nbsp;&nbsp;
153
- <a href="#M000033">register_template</a>&nbsp;&nbsp;
154
- <a href="#M000039">render</a>&nbsp;&nbsp;
155
- <a href="#M000036">store_cachefile</a>&nbsp;&nbsp;
156
- <a href="#M000030">to_filename</a>&nbsp;&nbsp;
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
157
  </div>
158
158
  </div>
159
159
 
@@ -175,11 +175,11 @@ ex. file &#8216;main.rb&#8216;
175
175
  <div id="methods">
176
176
  <h3 class="section-bar">Public Class methods</h3>
177
177
 
178
- <div id="method-M000029" class="method-detail">
179
- <a name="M000029"></a>
178
+ <div id="method-M000031" class="method-detail">
179
+ <a name="M000031"></a>
180
180
 
181
181
  <div class="method-heading">
182
- <a href="#M000029" class="method-signature">
182
+ <a href="#M000031" class="method-signature">
183
183
  <span class="method-name">new</span><span class="method-args">(options={})</span>
184
184
  </a>
185
185
  </div>
@@ -219,10 +219,10 @@ href="Template.html">Tenjin::Template</a>)
219
219
  </td></tr>
220
220
  </table>
221
221
  <p><a class="source-toggle" href="#"
222
- onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
223
- <div class="method-source-code" id="M000029-source">
222
+ onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
223
+ <div class="method-source-code" id="M000031-source">
224
224
  <pre>
225
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 812</span>
225
+ <span class="ruby-comment cmt"># File lib/tenjin.rb, line 822</span>
226
226
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span>={})
227
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
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>
@@ -241,21 +241,21 @@ href="Template.html">Tenjin::Template</a>)
241
241
 
242
242
  <h3 class="section-bar">Public Instance methods</h3>
243
243
 
244
- <div id="method-M000034" class="method-detail">
245
- <a name="M000034"></a>
244
+ <div id="method-M000036" class="method-detail">
245
+ <a name="M000036"></a>
246
246
 
247
247
  <div class="method-heading">
248
- <a href="#M000034" class="method-signature">
248
+ <a href="#M000036" class="method-signature">
249
249
  <span class="method-name">cachename</span><span class="method-args">(filename)</span>
250
250
  </a>
251
251
  </div>
252
252
 
253
253
  <div class="method-description">
254
254
  <p><a class="source-toggle" href="#"
255
- onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
256
- <div class="method-source-code" id="M000034-source">
255
+ onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
256
+ <div class="method-source-code" id="M000036-source">
257
257
  <pre>
258
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 861</span>
258
+ <span class="ruby-comment cmt"># File lib/tenjin.rb, line 871</span>
259
259
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cachename</span>(<span class="ruby-identifier">filename</span>)
260
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
261
  <span class="ruby-keyword kw">end</span>
@@ -264,11 +264,11 @@ href="Template.html">Tenjin::Template</a>)
264
264
  </div>
265
265
  </div>
266
266
 
267
- <div id="method-M000035" class="method-detail">
268
- <a name="M000035"></a>
267
+ <div id="method-M000037" class="method-detail">
268
+ <a name="M000037"></a>
269
269
 
270
270
  <div class="method-heading">
271
- <a href="#M000035" class="method-signature">
271
+ <a href="#M000037" class="method-signature">
272
272
  <span class="method-name">create_template</span><span class="method-args">(filename, _context=nil)</span>
273
273
  </a>
274
274
  </div>
@@ -278,10 +278,10 @@ href="Template.html">Tenjin::Template</a>)
278
278
  create template object from file
279
279
  </p>
280
280
  <p><a class="source-toggle" href="#"
281
- onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
282
- <div class="method-source-code" id="M000035-source">
281
+ onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
282
+ <div class="method-source-code" id="M000037-source">
283
283
  <pre>
284
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 866</span>
284
+ <span class="ruby-comment cmt"># File lib/tenjin.rb, line 876</span>
285
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
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
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>()
@@ -307,11 +307,11 @@ create template object from file
307
307
  </div>
308
308
  </div>
309
309
 
310
- <div id="method-M000031" class="method-detail">
311
- <a name="M000031"></a>
310
+ <div id="method-M000033" class="method-detail">
311
+ <a name="M000033"></a>
312
312
 
313
313
  <div class="method-heading">
314
- <a href="#M000031" class="method-signature">
314
+ <a href="#M000033" class="method-signature">
315
315
  <span class="method-name">find_template_file</span><span class="method-args">(template_name)</span>
316
316
  </a>
317
317
  </div>
@@ -321,10 +321,10 @@ create template object from file
321
321
  find template filename
322
322
  </p>
323
323
  <p><a class="source-toggle" href="#"
324
- onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
325
- <div class="method-source-code" id="M000031-source">
324
+ onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
325
+ <div class="method-source-code" id="M000033-source">
326
326
  <pre>
327
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 831</span>
327
+ <span class="ruby-comment cmt"># File lib/tenjin.rb, line 841</span>
328
328
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">find_template_file</span>(<span class="ruby-identifier">template_name</span>)
329
329
  <span class="ruby-identifier">filename</span> = <span class="ruby-identifier">to_filename</span>(<span class="ruby-identifier">template_name</span>)
330
330
  <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@path</span>
@@ -342,11 +342,11 @@ find template filename
342
342
  </div>
343
343
  </div>
344
344
 
345
- <div id="method-M000038" class="method-detail">
346
- <a name="M000038"></a>
345
+ <div id="method-M000040" class="method-detail">
346
+ <a name="M000040"></a>
347
347
 
348
348
  <div class="method-heading">
349
- <a href="#M000038" class="method-signature">
349
+ <a href="#M000040" class="method-signature">
350
350
  <span class="method-name">get_template</span><span class="method-args">(template_name, _context=nil)</span>
351
351
  </a>
352
352
  </div>
@@ -356,10 +356,10 @@ find template filename
356
356
  get template object
357
357
  </p>
358
358
  <p><a class="source-toggle" href="#"
359
- onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
360
- <div class="method-source-code" id="M000038-source">
359
+ onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
360
+ <div class="method-source-code" id="M000040-source">
361
361
  <pre>
362
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 908</span>
362
+ <span class="ruby-comment cmt"># File lib/tenjin.rb, line 918</span>
363
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
364
  <span class="ruby-identifier">template</span> = <span class="ruby-ivar">@templates</span>[<span class="ruby-identifier">template_name</span>]
365
365
  <span class="ruby-identifier">t</span> = <span class="ruby-identifier">template</span>
@@ -375,21 +375,21 @@ get template object
375
375
  </div>
376
376
  </div>
377
377
 
378
- <div id="method-M000040" class="method-detail">
379
- <a name="M000040"></a>
378
+ <div id="method-M000042" class="method-detail">
379
+ <a name="M000042"></a>
380
380
 
381
381
  <div class="method-heading">
382
- <a href="#M000040" class="method-signature">
382
+ <a href="#M000042" class="method-signature">
383
383
  <span class="method-name">hook_context</span><span class="method-args">(context)</span>
384
384
  </a>
385
385
  </div>
386
386
 
387
387
  <div class="method-description">
388
388
  <p><a class="source-toggle" href="#"
389
- onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
390
- <div class="method-source-code" id="M000040-source">
389
+ onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
390
+ <div class="method-source-code" id="M000042-source">
391
391
  <pre>
392
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 945</span>
392
+ <span class="ruby-comment cmt"># File lib/tenjin.rb, line 955</span>
393
393
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">hook_context</span>(<span class="ruby-identifier">context</span>)
394
394
  <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">context</span>
395
395
  <span class="ruby-identifier">context</span> = <span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>
@@ -405,11 +405,11 @@ get template object
405
405
  </div>
406
406
  </div>
407
407
 
408
- <div id="method-M000037" class="method-detail">
409
- <a name="M000037"></a>
408
+ <div id="method-M000039" class="method-detail">
409
+ <a name="M000039"></a>
410
410
 
411
411
  <div class="method-heading">
412
- <a href="#M000037" class="method-signature">
412
+ <a href="#M000039" class="method-signature">
413
413
  <span class="method-name">load_cachefile</span><span class="method-args">(cache_filename, template)</span>
414
414
  </a>
415
415
  </div>
@@ -419,10 +419,10 @@ get template object
419
419
  load template from cache file
420
420
  </p>
421
421
  <p><a class="source-toggle" href="#"
422
- onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
423
- <div class="method-source-code" id="M000037-source">
422
+ onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
423
+ <div class="method-source-code" id="M000039-source">
424
424
  <pre>
425
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 899</span>
425
+ <span class="ruby-comment cmt"># File lib/tenjin.rb, line 909</span>
426
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
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
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>)
@@ -435,11 +435,11 @@ load template from cache file
435
435
  </div>
436
436
  </div>
437
437
 
438
- <div id="method-M000032" class="method-detail">
439
- <a name="M000032"></a>
438
+ <div id="method-M000034" class="method-detail">
439
+ <a name="M000034"></a>
440
440
 
441
441
  <div class="method-heading">
442
- <a href="#M000032" class="method-signature">
442
+ <a href="#M000034" class="method-signature">
443
443
  <span class="method-name">read_template_file</span><span class="method-args">(filename, _context)</span>
444
444
  </a>
445
445
  </div>
@@ -449,10 +449,10 @@ load template from cache file
449
449
  read template file and preprocess it
450
450
  </p>
451
451
  <p><a class="source-toggle" href="#"
452
- onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
453
- <div class="method-source-code" id="M000032-source">
452
+ onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
453
+ <div class="method-source-code" id="M000034-source">
454
454
  <pre>
455
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 845</span>
455
+ <span class="ruby-comment cmt"># File lib/tenjin.rb, line 855</span>
456
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
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
458
  <span class="ruby-identifier">_context</span> <span class="ruby-operator">||=</span> {}
@@ -467,11 +467,11 @@ read template file and preprocess it
467
467
  </div>
468
468
  </div>
469
469
 
470
- <div id="method-M000033" class="method-detail">
471
- <a name="M000033"></a>
470
+ <div id="method-M000035" class="method-detail">
471
+ <a name="M000035"></a>
472
472
 
473
473
  <div class="method-heading">
474
- <a href="#M000033" class="method-signature">
474
+ <a href="#M000035" class="method-signature">
475
475
  <span class="method-name">register_template</span><span class="method-args">(template_name, template)</span>
476
476
  </a>
477
477
  </div>
@@ -481,10 +481,10 @@ read template file and preprocess it
481
481
  register template object
482
482
  </p>
483
483
  <p><a class="source-toggle" href="#"
484
- onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
485
- <div class="method-source-code" id="M000033-source">
484
+ onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
485
+ <div class="method-source-code" id="M000035-source">
486
486
  <pre>
487
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 856</span>
487
+ <span class="ruby-comment cmt"># File lib/tenjin.rb, line 866</span>
488
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
489
  <span class="ruby-comment cmt">#template.timestamp = Time.new unless template.timestamp</span>
490
490
  <span class="ruby-ivar">@templates</span>[<span class="ruby-identifier">template_name</span>] = <span class="ruby-identifier">template</span>
@@ -494,11 +494,11 @@ register template object
494
494
  </div>
495
495
  </div>
496
496
 
497
- <div id="method-M000039" class="method-detail">
498
- <a name="M000039"></a>
497
+ <div id="method-M000041" class="method-detail">
498
+ <a name="M000041"></a>
499
499
 
500
500
  <div class="method-heading">
501
- <a href="#M000039" class="method-signature">
501
+ <a href="#M000041" class="method-signature">
502
502
  <span class="method-name">render</span><span class="method-args">(template_name, context=Context.new, layout=true)</span>
503
503
  </a>
504
504
  </div>
@@ -512,10 +512,10 @@ template is used. if argument &#8216;layout&#8217; is string, it is
512
512
  regarded as layout template name.
513
513
  </p>
514
514
  <p><a class="source-toggle" href="#"
515
- onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
516
- <div class="method-source-code" id="M000039-source">
515
+ onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
516
+ <div class="method-source-code" id="M000041-source">
517
517
  <pre>
518
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 924</span>
518
+ <span class="ruby-comment cmt"># File lib/tenjin.rb, line 934</span>
519
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
520
  <span class="ruby-comment cmt">#context = Context.new(context) if context.is_a?(Hash)</span>
521
521
  <span class="ruby-identifier">context</span> = <span class="ruby-identifier">hook_context</span>(<span class="ruby-identifier">context</span>)
@@ -524,15 +524,15 @@ regarded as layout template name.
524
524
  <span class="ruby-identifier">_buf</span> = <span class="ruby-identifier">context</span>.<span class="ruby-identifier">_buf</span>
525
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
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-value str">'_layout'</span>].<span class="ruby-identifier">nil?</span>
528
- <span class="ruby-identifier">layout</span> = <span class="ruby-identifier">context</span>[<span class="ruby-value str">'_layout'</span>]
529
- <span class="ruby-identifier">context</span>[<span class="ruby-value str">'_layout'</span>] = <span class="ruby-keyword kw">nil</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
530
  <span class="ruby-keyword kw">end</span>
531
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
532
  <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">layout</span>
533
533
  <span class="ruby-identifier">template_name</span> = <span class="ruby-identifier">layout</span>
534
534
  <span class="ruby-identifier">layout</span> = <span class="ruby-keyword kw">false</span>
535
- <span class="ruby-identifier">context</span>[<span class="ruby-value str">'_content'</span>] = <span class="ruby-identifier">output</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
536
  <span class="ruby-keyword kw">end</span>
537
537
  <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">output</span>
538
538
  <span class="ruby-keyword kw">end</span>
@@ -541,11 +541,11 @@ regarded as layout template name.
541
541
  </div>
542
542
  </div>
543
543
 
544
- <div id="method-M000036" class="method-detail">
545
- <a name="M000036"></a>
544
+ <div id="method-M000038" class="method-detail">
545
+ <a name="M000038"></a>
546
546
 
547
547
  <div class="method-heading">
548
- <a href="#M000036" class="method-signature">
548
+ <a href="#M000038" class="method-signature">
549
549
  <span class="method-name">store_cachefile</span><span class="method-args">(cache_filename, template)</span>
550
550
  </a>
551
551
  </div>
@@ -555,10 +555,10 @@ regarded as layout template name.
555
555
  store template into cache file
556
556
  </p>
557
557
  <p><a class="source-toggle" href="#"
558
- onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
559
- <div class="method-source-code" id="M000036-source">
558
+ onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
559
+ <div class="method-source-code" id="M000038-source">
560
560
  <pre>
561
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 888</span>
561
+ <span class="ruby-comment cmt"># File lib/tenjin.rb, line 898</span>
562
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
563
  <span class="ruby-identifier">s</span> = <span class="ruby-identifier">template</span>.<span class="ruby-identifier">script</span>
564
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>
@@ -573,11 +573,11 @@ store template into cache file
573
573
  </div>
574
574
  </div>
575
575
 
576
- <div id="method-M000030" class="method-detail">
577
- <a name="M000030"></a>
576
+ <div id="method-M000032" class="method-detail">
577
+ <a name="M000032"></a>
578
578
 
579
579
  <div class="method-heading">
580
- <a href="#M000030" class="method-signature">
580
+ <a href="#M000032" class="method-signature">
581
581
  <span class="method-name">to_filename</span><span class="method-args">(template_name)</span>
582
582
  </a>
583
583
  </div>
@@ -588,10 +588,10 @@ convert short name into filename (ex. &#8217;:list&#8217; =&gt;
588
588
  &#8216;template/list.rb.html&#8217;)
589
589
  </p>
590
590
  <p><a class="source-toggle" href="#"
591
- onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
592
- <div class="method-source-code" id="M000030-source">
591
+ onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
592
+ <div class="method-source-code" id="M000032-source">
593
593
  <pre>
594
- <span class="ruby-comment cmt"># File lib/tenjin.rb, line 825</span>
594
+ <span class="ruby-comment cmt"># File lib/tenjin.rb, line 835</span>
595
595
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_filename</span>(<span class="ruby-identifier">template_name</span>)
596
596
  <span class="ruby-identifier">name</span> = <span class="ruby-identifier">template_name</span>
597
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>