kwartz 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. data/ChangeLog +36 -1
  2. data/LGPL +504 -0
  3. data/README.txt +16 -2
  4. data/bin/kwartz +1 -1
  5. data/doc-api/classes/Kwartz.html +47 -1
  6. data/doc-api/classes/Kwartz/Assertion.html +6 -6
  7. data/doc-api/classes/Kwartz/AssertionError.html +6 -6
  8. data/doc-api/classes/Kwartz/AttrInfo.html +42 -42
  9. data/doc-api/classes/Kwartz/BaseError.html +12 -12
  10. data/doc-api/classes/Kwartz/BaseTranslator.html +210 -43
  11. data/doc-api/classes/Kwartz/CharacterType.html +24 -24
  12. data/doc-api/classes/Kwartz/CommandOptionError.html +7 -7
  13. data/doc-api/classes/Kwartz/CommandOptions.html +49 -49
  14. data/doc-api/classes/Kwartz/Config.html +6 -1
  15. data/doc-api/classes/Kwartz/ConvertError.html +14 -14
  16. data/doc-api/classes/Kwartz/Converter.html +31 -30
  17. data/doc-api/classes/Kwartz/CssStyleParser.html +79 -57
  18. data/doc-api/classes/Kwartz/Defun.html +313 -0
  19. data/doc-api/classes/Kwartz/DocumentRuleset.html +58 -58
  20. data/doc-api/classes/Kwartz/ElementExpander.html +32 -32
  21. data/doc-api/classes/Kwartz/ElementInfo.html +29 -29
  22. data/doc-api/classes/Kwartz/ElementRuleset.html +126 -96
  23. data/doc-api/classes/Kwartz/EperlHandler.html +108 -84
  24. data/doc-api/classes/Kwartz/EperlTranslator.html +7 -7
  25. data/doc-api/classes/Kwartz/ErubisHandler.html +2 -2
  26. data/doc-api/classes/Kwartz/ErubisTranslator.html +8 -8
  27. data/doc-api/classes/Kwartz/ErubyHandler.html +2 -220
  28. data/doc-api/classes/Kwartz/ErubyTranslator.html +7 -7
  29. data/doc-api/classes/Kwartz/ExpandStatement.html +20 -20
  30. data/doc-api/classes/Kwartz/Handler.html +122 -117
  31. data/doc-api/classes/Kwartz/HandlerArgument.html +215 -0
  32. data/doc-api/classes/Kwartz/Helper.html +112 -0
  33. data/doc-api/classes/Kwartz/Helper/ActionViewHelper.html +221 -0
  34. data/doc-api/classes/Kwartz/Helper/RailsTemplate.html +630 -0
  35. data/doc-api/classes/Kwartz/JstlHandler.html +208 -193
  36. data/doc-api/classes/Kwartz/JstlTranslator.html +15 -15
  37. data/doc-api/classes/Kwartz/KwartzError.html +6 -6
  38. data/doc-api/classes/Kwartz/Main.html +39 -23
  39. data/doc-api/classes/Kwartz/NativeExpression.html +18 -18
  40. data/doc-api/classes/Kwartz/NativeStatement.html +25 -25
  41. data/doc-api/classes/Kwartz/Node.html +6 -6
  42. data/doc-api/classes/Kwartz/PIErubisHandler.html +113 -0
  43. data/doc-api/classes/Kwartz/PIErubisTranslator.html +200 -0
  44. data/doc-api/classes/Kwartz/ParseError.html +6 -6
  45. data/doc-api/classes/Kwartz/PhpHandler.html +102 -83
  46. data/doc-api/classes/Kwartz/PhpTranslator.html +14 -14
  47. data/doc-api/classes/Kwartz/PresentationLogicParser.html +136 -128
  48. data/doc-api/classes/Kwartz/PrintStatement.html +19 -19
  49. data/doc-api/classes/Kwartz/RailsHandler.html +121 -118
  50. data/doc-api/classes/Kwartz/RailsTranslator.html +7 -7
  51. data/doc-api/classes/Kwartz/RubyHandler.html +349 -0
  52. data/doc-api/classes/Kwartz/RubyStyleParser.html +85 -85
  53. data/doc-api/classes/Kwartz/RubyTranslator.html +218 -0
  54. data/doc-api/classes/Kwartz/StatementHelper.html +479 -0
  55. data/doc-api/classes/Kwartz/StrutsTranslator.html +12 -12
  56. data/doc-api/classes/Kwartz/TagInfo.html +28 -28
  57. data/doc-api/classes/Kwartz/TextConverter.html +28 -28
  58. data/doc-api/classes/Kwartz/Translator.html +42 -42
  59. data/doc-api/classes/Kwartz/Util.html +284 -0
  60. data/doc-api/created.rid +1 -1
  61. data/doc-api/files/__/README_txt.html +30 -3
  62. data/doc-api/files/kwartz/assert_rb.html +1 -1
  63. data/doc-api/files/kwartz/binding/eperl_rb.html +2 -2
  64. data/doc-api/files/kwartz/binding/erubis_rb.html +3 -3
  65. data/doc-api/files/kwartz/binding/eruby_rb.html +3 -2
  66. data/doc-api/files/kwartz/binding/jstl_rb.html +2 -2
  67. data/doc-api/files/kwartz/binding/php_rb.html +2 -2
  68. data/doc-api/files/kwartz/binding/pierubis_rb.html +116 -0
  69. data/doc-api/files/kwartz/binding/rails_rb.html +2 -2
  70. data/doc-api/files/kwartz/binding/ruby_rb.html +115 -0
  71. data/doc-api/files/kwartz/binding/struts_rb.html +1 -1
  72. data/doc-api/files/kwartz/config_rb.html +2 -2
  73. data/doc-api/files/kwartz/converter_rb.html +3 -2
  74. data/doc-api/files/kwartz/defun_rb.html +116 -0
  75. data/doc-api/files/kwartz/error_rb.html +1 -1
  76. data/doc-api/files/kwartz/helper/rails_rb.html +123 -0
  77. data/doc-api/files/kwartz/main_rb.html +5 -2
  78. data/doc-api/files/kwartz/node_rb.html +2 -2
  79. data/doc-api/files/kwartz/parser_rb.html +2 -2
  80. data/doc-api/files/kwartz/translator_rb.html +2 -2
  81. data/doc-api/files/kwartz/util/assert-text-equal_rb.html +1 -1
  82. data/doc-api/files/kwartz/util/testcase-helper_rb.html +2 -2
  83. data/doc-api/files/kwartz/util_rb.html +107 -0
  84. data/doc-api/files/kwartz_rb.html +3 -2
  85. data/doc-api/fr_class_index.html +11 -0
  86. data/doc-api/fr_file_index.html +5 -0
  87. data/doc-api/fr_method_index.html +242 -190
  88. data/doc/p-pattern.html +94 -94
  89. data/doc/reference.html +847 -612
  90. data/doc/users-guide.html +744 -241
  91. data/examples/rails1/README +2 -2
  92. data/examples/rails1/application_helper.rb +2 -27
  93. data/examples/rails1/link_to.plogic +5 -5
  94. data/examples/rails1/list.plogic +2 -2
  95. data/examples/rails2/app/controllers/application.rb +14 -0
  96. data/examples/rails2/app/controllers/groups_controller.rb +47 -0
  97. data/examples/rails2/app/controllers/members_controller.rb +56 -0
  98. data/examples/rails2/app/helpers/application_helper.rb +6 -0
  99. data/examples/rails2/app/helpers/groups_helper.rb +2 -0
  100. data/examples/rails2/app/helpers/members_helper.rb +2 -0
  101. data/examples/rails2/app/models/group.rb +2 -0
  102. data/examples/rails2/app/models/member.rb +3 -0
  103. data/examples/rails2/app/views/groups/_form.html +30 -0
  104. data/examples/rails2/app/views/groups/_form.plogic +11 -0
  105. data/examples/rails2/app/views/groups/_link.plogic +19 -0
  106. data/examples/rails2/app/views/groups/_read.plogic +7 -0
  107. data/examples/rails2/app/views/groups/edit.cfg.yaml +2 -0
  108. data/examples/rails2/app/views/groups/edit.html +26 -0
  109. data/examples/rails2/app/views/groups/edit.plogic +9 -0
  110. data/examples/rails2/app/views/groups/list.html +48 -0
  111. data/examples/rails2/app/views/groups/list.plogic +32 -0
  112. data/examples/rails2/app/views/groups/new.cfg.yaml +2 -0
  113. data/examples/rails2/app/views/groups/new.html +27 -0
  114. data/examples/rails2/app/views/groups/new.plogic +9 -0
  115. data/examples/rails2/app/views/groups/show.html +27 -0
  116. data/examples/rails2/app/views/groups/show.plogic +2 -0
  117. data/examples/rails2/app/views/layouts/groups.html +23 -0
  118. data/examples/rails2/app/views/layouts/groups.plogic +11 -0
  119. data/examples/rails2/app/views/layouts/members.html +23 -0
  120. data/examples/rails2/app/views/layouts/members.plogic +11 -0
  121. data/examples/rails2/app/views/layouts/members2.html +24 -0
  122. data/examples/rails2/app/views/layouts/members2.plogic +11 -0
  123. data/examples/rails2/app/views/members/_form.plogic +27 -0
  124. data/examples/rails2/app/views/members/_link.plogic +19 -0
  125. data/examples/rails2/app/views/members/_read.plogic +29 -0
  126. data/examples/rails2/app/views/members/edit.cfg.yaml +6 -0
  127. data/examples/rails2/app/views/members/edit.html +27 -0
  128. data/examples/rails2/app/views/members/edit.plogic +10 -0
  129. data/examples/rails2/app/views/members/list.html +53 -0
  130. data/examples/rails2/app/views/members/list.plogic +32 -0
  131. data/examples/rails2/app/views/members/new.html +61 -0
  132. data/examples/rails2/app/views/members/new.plogic +17 -0
  133. data/examples/rails2/app/views/members/show.html +41 -0
  134. data/examples/rails2/app/views/members/show.plogic +3 -0
  135. data/examples/rails2/db/create-tables.mysql.sql +27 -0
  136. data/examples/rails2/db/create-tables.pgsql.sql +27 -0
  137. data/examples/rails2/db/insert-data.sql +21 -0
  138. data/examples/rails2/db/tabledef.yaml +51 -0
  139. data/kwartz.gemspec +4 -4
  140. data/lib/kwartz.rb +10 -2
  141. data/lib/kwartz/assert.rb +1 -1
  142. data/lib/kwartz/binding/eperl.rb +85 -61
  143. data/lib/kwartz/binding/erubis.rb +6 -8
  144. data/lib/kwartz/binding/eruby.rb +5 -120
  145. data/lib/kwartz/binding/jstl.rb +116 -101
  146. data/lib/kwartz/binding/php.rb +79 -60
  147. data/lib/kwartz/binding/pierubis.rb +58 -0
  148. data/lib/kwartz/binding/rails.rb +45 -42
  149. data/lib/kwartz/binding/ruby.rb +193 -0
  150. data/lib/kwartz/binding/struts.rb +1 -1
  151. data/lib/kwartz/config.rb +4 -3
  152. data/lib/kwartz/converter.rb +231 -68
  153. data/lib/kwartz/defun.rb +126 -0
  154. data/lib/kwartz/error.rb +1 -1
  155. data/lib/kwartz/helper/rails.rb +437 -0
  156. data/lib/kwartz/main.rb +30 -38
  157. data/lib/kwartz/node.rb +46 -31
  158. data/lib/kwartz/parser.rb +43 -15
  159. data/lib/kwartz/translator.rb +104 -6
  160. data/lib/kwartz/util.rb +113 -0
  161. data/lib/kwartz/util/assert-text-equal.rb +1 -1
  162. data/lib/kwartz/util/testcase-helper.rb +26 -8
  163. data/test/test-compile.rb +3 -3
  164. data/test/test-compile.yaml +135 -5
  165. data/test/test-converter.rb +16 -8
  166. data/test/test-converter.yaml +307 -76
  167. data/test/test-directives.rb +1 -1
  168. data/test/test-directives.yaml +964 -979
  169. data/test/test-main.rb +61 -146
  170. data/test/test-main.yaml +235 -0
  171. data/test/test-parser.rb +10 -12
  172. data/test/test-parser.yaml +484 -326
  173. data/test/test-rails.rb +1 -1
  174. data/test/test-rails.yaml +37 -37
  175. data/test/test-ruleset.rb +1 -1
  176. data/test/test-ruleset.yaml +34 -40
  177. data/test/test.rb +1 -1
  178. metadata +82 -3
  179. data/COPYING +0 -340
@@ -16,7 +16,7 @@
16
16
  <div align="left"><h1>Kwartz 3.0 Users' Guide</h1></div>
17
17
  <div align="left">
18
18
  Makoto Kuwata &lt;kwa(at)kuwata-lab.com&gt;<br>
19
- last update: $Date: 2006-05-22 22:25:43 +0900 (Mon, 22 May 2006) $<br>
19
+ last update: $Date: 2006-09-24 19:37:59 +0900 (Sun, 24 Sep 2006) $<br>
20
20
  </div>
21
21
 
22
22
  <a name="preface"></a>
@@ -59,6 +59,8 @@ a template system which realized the concept of 'Independence of Presentation Lo
59
59
  </li>
60
60
  <li><a href="#directives">Directives</a>
61
61
  </li>
62
+ <li><a href="#embed_expr">Embed Expression in Presentation Data</a>
63
+ </li>
62
64
  <li><a href="#escape">Escape</a>
63
65
  </li>
64
66
  <li><a href="#langs">Multi-language</a>
@@ -75,19 +77,35 @@ a template system which realized the concept of 'Independence of Presentation Lo
75
77
  </li>
76
78
  <li><a href="#begin">Add Code at Beginning/End of Document</a>
77
79
  </li>
80
+ <li><a href="#detail-defun">Compile Template into a Function of Ruby or PHP</a>
81
+ </li>
82
+ </ul>
83
+ </li>
84
+ <li><a href="#rails">Ruby on Rails Support</a>
85
+ <ul>
86
+ <li><a href="#rails_template">Support of Ruby on Rails</a>
87
+ </li>
88
+ <li><a href="#rails_start_link_tag"><code>link_to()</code> method in Ruby on Rails</a>
89
+ </li>
90
+ <li><a href="#rails-layout">Layout Option in Controller</a>
91
+ </li>
92
+ <li><a href="#rails-scaffold">Scaffold Kwartz Template</a>
93
+ </li>
94
+ <li><a href="#rails-helper-methods">Rails Helper Methods</a>
95
+ </li>
78
96
  </ul>
79
97
  </li>
80
98
  <li><a href="#topics">Other Topics</a>
81
99
  <ul>
82
- <li><a href="#restriction1">Restrictions around presentation logic</a>
100
+ <li><a href="#topics-restriction1">Restrictions around presentation logic</a>
83
101
  </li>
84
- <li><a href="#restriction2">Restrictions around presentation data</a>
102
+ <li><a href="#topics-restriction2">Restrictions around presentation data</a>
85
103
  </li>
86
- <li><a href="#makefile">Makefile and Rakefile</a>
104
+ <li><a href="#topics-makefile">Makefile and Rakefile</a>
87
105
  </li>
88
- <li><a href="#kwartz-lib">Use Kwartz as Library</a>
106
+ <li><a href="#topics-kwartz-lib">Use Kwartz as Library</a>
89
107
  </li>
90
- <li><a href="#start_link_to"><code>link_to()</code> method in Ruby on Rails</a>
108
+ <li><a href="#topics-erubis">Use Kwartz with Non-Supported Language</a>
91
109
  </li>
92
110
  </ul>
93
111
  </li>
@@ -103,7 +121,7 @@ a template system which realized the concept of 'Independence of Presentation Lo
103
121
  <a name="whatis"></a>
104
122
  <h3 class="section2">What's Kwartz?</h3>
105
123
  <p>Kwartz<sup>(<a href="#fnref:2" name="fnlink:2">*2</a>)</sup> is a template system
106
- which realized the concept of <b>'Independence of Presentation Logic'(IoPL)</b>.
124
+ which realized the concept of <strong>'Independence of Presentation Logic'(IoPL)</strong>.
107
125
  It means that Kwartz separates presentaion logics from both presentation data (typically HTML document) and business logics.
108
126
  </p>
109
127
  <p>You know CSS (Cascading Style Sheet). CSS separates design from HTML file.
@@ -181,7 +199,7 @@ Doesn't break HTML design at all</dt>
181
199
  <code>{foreach ...}{/foreach}</code> in <a href="http://smarty.php.net/">Smarty</a> or
182
200
  <code>#foreach(...)</code> in <a href="http://jakarta.apache.org/velocity/">Jakarta Velocity</a>.
183
201
  These directives break the HTML design of template.
184
- Kwartz doesn't break HTML design because Kwartz uses id or title attributes for marking in an HTML template.
202
+ Kwartz doesn't break HTML design because Kwartz uses id or kw:d attributes for marking in an HTML template.
185
203
  </p>
186
204
  </dd>
187
205
  <dt class="dt2">
@@ -220,9 +238,9 @@ They may be described in separate files.
220
238
  <p>This is an example of a presentation data file.
221
239
  </p>
222
240
  <ul type="disc">
223
- <li>'<b><code>id="list1"</code></b>' means "I'll operate this element in presentation logic" (called 'marking' in Kwartz).
241
+ <li>'<strong><code>id="list1"</code></strong>' means "I'll operate this element in presentation logic" (called 'marking' in Kwartz).
224
242
  </li>
225
- <li>'<b><code>id="mark:item1"</code></b>' is also an marking.
243
+ <li>'<strong><code>id="mark:item1"</code></strong>' is also an marking.
226
244
  Difference between <code>id="mark:item1"</code> and <code>id="item1"</code> is that id attribute in the former format is removed automatically and the latter format is leaved.
227
245
  </li>
228
246
  </ul>
@@ -230,8 +248,8 @@ They may be described in separate files.
230
248
  </p>
231
249
  <a name="example1.html"></a>
232
250
  <pre class="program">&lt;table&gt;
233
- &lt;tr <b>id="list1"</b>&gt;
234
- &lt;td <b>id="mark:item1"</b>&gt;foo&lt;/td&gt;
251
+ &lt;tr <strong>id="list1"</strong>&gt;
252
+ &lt;td <strong>id="mark:item1"</strong>&gt;foo&lt;/td&gt;
235
253
  &lt;/tr&gt;
236
254
  &lt;/table&gt;
237
255
  </pre>
@@ -239,24 +257,24 @@ They may be described in separate files.
239
257
  In presentation logic, you can operate on elements which are marked in presentation data.
240
258
  </p>
241
259
  <ul type="disc">
242
- <li>'<b><code>#list1 { ... }</code></b>' represents an element marked with name 'list1' (= '&lt;tr&gt;...&lt;/tr&gt;')
260
+ <li>'<strong><code>#list1 { ... }</code></strong>' represents an element marked with name 'list1' (= '&lt;tr&gt;...&lt;/tr&gt;')
243
261
  <ul type="circle">
244
- <li>'<b><code>logic: { ... }</code></b>' represents presentation logic of the element.
262
+ <li>'<strong><code>logic: { ... }</code></strong>' represents presentation logic of the element.
245
263
  </li>
246
- <li>'<b><code>_stag</code></b>' represents a start tag (= '&lt;tr&gt;').
264
+ <li>'<strong><code>_stag</code></strong>' represents a start tag (= '&lt;tr&gt;').
247
265
  </li>
248
- <li>'<b><code>_cont</code></b>' represents content(= '&lt;td id="mark:item1"&gt;foo&lt;/td&gt;').
266
+ <li>'<strong><code>_cont</code></strong>' represents content(= '&lt;td id="mark:item1"&gt;foo&lt;/td&gt;').
249
267
  </li>
250
- <li>'<b><code>_etag</code></b>' represents an end tag(= '&lt;/tr&gt;').
268
+ <li>'<strong><code>_etag</code></strong>' represents an end tag(= '&lt;/tr&gt;').
251
269
  </li>
252
- <li>'<b><code>for <i>var</i> in <i>list</i> ...</code></b>' is a Ruby code to loop.
270
+ <li>'<strong><code>for <em>var</em> in <em>list</em> ...</code></strong>' is a Ruby code to loop.
253
271
  In this case, the element(= start-tag + content + end-tag) is looped.
254
272
  </li>
255
273
  </ul>
256
274
  </li>
257
- <li>'<b><code>#item1 { ... }</code></b>' represents an element marked with name 'item1' (= '&lt;td&gt;...&lt;/td&gt;').
275
+ <li>'<strong><code>#item1 { ... }</code></strong>' represents an element marked with name 'item1' (= '&lt;td&gt;...&lt;/td&gt;').
258
276
  <ul type="circle">
259
- <li>'<b><code>value: <i>expression</i>;</code></b>' represents that the content of the element is replaced by value of <code><i>expression</i></code>, which is value of a variable <code>member</code> in this case.
277
+ <li>'<strong><code>value: <em>expression</em>;</code></strong>' represents that the content of the element is replaced by value of <code><em>expression</em></code>, which is value of a variable <code>member</code> in this case.
260
278
  </li>
261
279
  </ul>
262
280
  </li>
@@ -265,18 +283,18 @@ In presentation logic, you can operate on elements which are marked in presentat
265
283
  <div class="program_caption">
266
284
  Presentation logic file(example1.plogic):</div>
267
285
  <pre class="program">/* The element which is marked by 'id="list1"' */
268
- <b>#list1</b> {
286
+ <strong>#list1</strong> {
269
287
  logic: {
270
288
  for member in @members
271
- <b>_stag</b> # start tag
272
- <b>_cont</b> # content
273
- <b>_etag</b> # end tag
289
+ <strong>_stag</strong> # start tag
290
+ <strong>_cont</strong> # content
291
+ <strong>_etag</strong> # end tag
274
292
  end
275
293
  }
276
294
  }
277
295
 
278
296
  /* The element which is marked by 'id="mark:item1"' */
279
- <b>#item1</b> {
297
+ <strong>#item1</strong> {
280
298
  /* replace the content with value of a variable 'member' */
281
299
  value: member;
282
300
  }
@@ -314,10 +332,10 @@ generated eRuby script</div>
314
332
  <div class="program_caption">
315
333
  Presentation Data (example2.html):</div>
316
334
  <pre class="program">&lt;table&gt;
317
- &lt;tr bgcolor="#CCCCFF" <b>id="mark:list"</b>&gt;
318
- &lt;td <b>id="mark:name"</b>&gt;foo&lt;/td&gt;
335
+ &lt;tr bgcolor="#CCCCFF" <strong>id="mark:list"</strong>&gt;
336
+ &lt;td <strong>id="mark:name"</strong>&gt;foo&lt;/td&gt;
319
337
  &lt;td&gt;
320
- &lt;a href="mailto:foo@mail.com" <b>id="mark:email"</b>&gt;foo@mail.com&lt;/a&gt;
338
+ &lt;a href="mailto:foo@mail.com" <strong>id="mark:email"</strong>&gt;foo@mail.com&lt;/a&gt;
321
339
  &lt;/td&gt;
322
340
  &lt;/tr&gt;
323
341
  &lt;/table&gt;
@@ -332,7 +350,7 @@ In the presentation logic, you should detect whether odd or even line in the ite
332
350
  * an element which is marked by 'id="mark:list"'
333
351
  * - print value of a variable 'color' as bgcolor attribute value.
334
352
  */
335
- <b>#list</b> {
353
+ <strong>#list</strong> {
336
354
  attrs: "bgcolor" color;
337
355
  logic: {
338
356
  @members.each_with_index do |member, i|
@@ -348,7 +366,7 @@ In the presentation logic, you should detect whether odd or even line in the ite
348
366
  * an element which is marked by 'id="mark:name"':
349
367
  * - print value of member[:name] as content of the element.
350
368
  */
351
- <b>#name</b> {
369
+ <strong>#name</strong> {
352
370
  value: member[:name];
353
371
  }
354
372
 
@@ -357,7 +375,7 @@ In the presentation logic, you should detect whether odd or even line in the ite
357
375
  * - print value of member[:email] as contentn of the element.
358
376
  * - print "mailto:" and member[:email] as href attribute value.
359
377
  */
360
- <b>#email</b> {
378
+ <strong>#email</strong> {
361
379
  value: member[:email];
362
380
  attrs: "href" "mailto:#{member[:email]}";
363
381
  }
@@ -375,15 +393,15 @@ compilation</div>
375
393
  <div class="program_caption">
376
394
  output script</div>
377
395
  <pre class="program">&lt;table&gt;
378
- <b>&lt;% @members.each_with_index do |member, i| %&gt;</b>
379
- <b>&lt;% color = i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'; %&gt;</b>
380
- &lt;tr bgcolor="<b>&lt;%= color %&gt;</b>"&gt;
381
- &lt;td&gt;<b>&lt;%= member[:name] %&gt;</b>&lt;/td&gt;
396
+ <strong>&lt;% @members.each_with_index do |member, i| %&gt;</strong>
397
+ <strong>&lt;% color = i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'; %&gt;</strong>
398
+ &lt;tr bgcolor="<strong>&lt;%= color %&gt;</strong>"&gt;
399
+ &lt;td&gt;<strong>&lt;%= member[:name] %&gt;</strong>&lt;/td&gt;
382
400
  &lt;td&gt;
383
- &lt;a href="<b>&lt;%= "mailto:#{member[:email]}" %&gt;</b>"&gt;<b>&lt;%= member[:email] %&gt;</b>&lt;/a&gt;
401
+ &lt;a href="<strong>&lt;%= "mailto:#{member[:email]}" %&gt;</strong>"&gt;<strong>&lt;%= member[:email] %&gt;</strong>&lt;/a&gt;
384
402
  &lt;/td&gt;
385
403
  &lt;/tr&gt;
386
- <b>&lt;% end %&gt;</b>
404
+ <strong>&lt;% end %&gt;</strong>
387
405
  &lt;/table&gt;
388
406
  </pre>
389
407
  <br>
@@ -552,42 +570,42 @@ These are similar to CSS. If you are familiar with CSS, you'll be so with Kwartz
552
570
  </p>
553
571
  <dl class="dl3">
554
572
  <dt class="dt3"><b>
555
- stag: <i>expr</i>; </b></dt>
573
+ stag: <em>expr</em>; </b></dt>
556
574
  <dd class="dd3">
557
575
  Replace start-tag by expression value.
558
576
  </dd>
559
577
  </dl>
560
578
  <dl class="dl3">
561
579
  <dt class="dt3"><b>
562
- etag: <i>expr</i>; </b></dt>
580
+ etag: <em>expr</em>; </b></dt>
563
581
  <dd class="dd3">
564
582
  Replace end-tag by expression value.
565
583
  </dd>
566
584
  </dl>
567
585
  <dl class="dl3">
568
586
  <dt class="dt3"><b>
569
- elem: <i>expr</i>; </b></dt>
587
+ elem: <em>expr</em>; </b></dt>
570
588
  <dd class="dd3">
571
589
  Replace elemnt by expression value.
572
590
  </dd>
573
591
  </dl>
574
592
  <dl class="dl3">
575
593
  <dt class="dt3"><b>
576
- cont: <i>expr</i>; </b></dt>
594
+ cont: <em>expr</em>; </b></dt>
577
595
  <dd class="dd3">
578
596
  Replace content of element by expressin value.
579
597
  </dd>
580
598
  </dl>
581
599
  <dl class="dl3">
582
600
  <dt class="dt3"><b>
583
- value: <i>expr</i>; </b></dt>
601
+ value: <em>expr</em>; </b></dt>
584
602
  <dd class="dd3">
585
- Equivarent to <code>cont: <i>expr</i></code>.
603
+ Equivarent to <code>cont: <em>expr</em></code>.
586
604
  </dd>
587
605
  </dl>
588
606
  <dl class="dl3">
589
607
  <dt class="dt3"><b>
590
- attrs: 'attrname' <i>expr</i>; </b></dt>
608
+ attrs: 'attrname' <em>expr</em>; </b></dt>
591
609
  <dd class="dd3">
592
610
  Replace attribute value by expression.
593
611
  The following is an example to specify some attributes.
@@ -601,7 +619,7 @@ attrs: 'attrname' <i>expr</i>; </b></dt>
601
619
  </dl>
602
620
  <dl class="dl3">
603
621
  <dt class="dt3"><b>
604
- append: <i>expr</i>; </b></dt>
622
+ append: <em>expr</em>; </b></dt>
605
623
  <dd class="dd3">
606
624
  Append expression value to tail of tag.
607
625
  This is used especially to add 'checked="checked"', 'selected="selected"'
@@ -635,38 +653,38 @@ The following is an examle to use Kwartz in Ruby on Rails.
635
653
  <a name="form1.html"></a>
636
654
  <div class="program_caption">
637
655
  presentation data (form1.html)</div>
638
- <pre class="program">&lt;form <b>id="form"</b>&gt;
639
- Name: &lt;input type="text" <b>id="member_name"</b>&gt;&lt;br&gt;
640
- Birthday: &lt;select <b>id="member_birth"</b>&gt;
656
+ <pre class="program">&lt;form <strong>id="form"</strong>&gt;
657
+ Name: &lt;input type="text" <strong>id="member_name"</strong>&gt;&lt;br&gt;
658
+ Birthday: &lt;select <strong>id="member_birth"</strong>&gt;
641
659
  &lt;option&gt; - &lt;/option&gt;
642
660
  &lt;/select&gt;&lt;br&gt;
643
- &lt;input type="submit" <b>id="submit"</b>&gt;
661
+ &lt;input type="submit" <strong>id="submit"</strong>&gt;
644
662
  &lt;/form&gt;
645
663
  </pre>
646
664
  <a name="form1.plogic"></a>
647
665
  <div class="program_caption">
648
666
  presentation logic (form1.plogic)</div>
649
- <pre class="program"><b>#form</b> {
650
- <b>stag:</b> start_form_tag :action=&gt;'new';
667
+ <pre class="program"><strong>#form</strong> {
668
+ <strong>stag:</strong> start_form_tag :action=&gt;'new';
651
669
  }
652
- <b>#member_name</b> {
653
- <b>elem:</b> text_field 'member', 'name';
670
+ <strong>#member_name</strong> {
671
+ <strong>elem:</strong> text_field 'member', 'name';
654
672
  }
655
- <b>#member_birth</b> {
656
- <b>elem:</b> date_select 'member', birth';
673
+ <strong>#member_birth</strong> {
674
+ <strong>elem:</strong> date_select 'member', birth';
657
675
  }
658
- <b>#submit</b> {
659
- <b>elem:</b> submit_to 'Submit';
676
+ <strong>#submit</strong> {
677
+ <strong>elem:</strong> submit_to 'Submit';
660
678
  }
661
679
  </pre>
662
680
  <a name="form1.expected"></a>
663
681
  <div class="terminal_caption">
664
682
  compile</div>
665
683
  <pre class="terminal">$ kwartz -p form1.plogic form1.html
666
- <b>&lt;%= start_form_tag :action=&gt;'new' %&gt;</b>
667
- Name: <b>&lt;%= text_field 'member', 'name' %&gt;</b>&lt;br&gt;
668
- Birthday: <b>&lt;%= date_select 'member', birth' %&gt;</b>&lt;br&gt;
669
- <b>&lt;%= submit_to 'Submit' %&gt;</b>
684
+ <strong>&lt;%= start_form_tag :action=&gt;'new' %&gt;</strong>
685
+ Name: <strong>&lt;%= text_field 'member', 'name' %&gt;</strong>&lt;br&gt;
686
+ Birthday: <strong>&lt;%= date_select 'member', birth' %&gt;</strong>&lt;br&gt;
687
+ <strong>&lt;%= submit_to 'Submit' %&gt;</strong>
670
688
  &lt;/form&gt;
671
689
  </pre>
672
690
  <br>
@@ -677,7 +695,7 @@ compile</div>
677
695
  <p>Presentation logic may be embedded into presentation data in Kwartz.
678
696
  You can choose to separate or not to sepearate presentation logic from presentation data.
679
697
  </p>
680
- <p>The reason to provide both solutions (separate or not) is <b>choosability</b>.
698
+ <p>The reason to provide both solutions (separate or not) is <strong>choosability</strong>.
681
699
  Some preferes to separate presentation logic from presentaion data, and others may
682
700
  prefere to mix them.
683
701
  Both approaches have own advantages and disadvantages.
@@ -687,34 +705,34 @@ Kwartz doesn't enforce you to adopt a solution.
687
705
  </p>
688
706
  <p>To embed presentation logic into presentation data, use directives.
689
707
  Directive is a command to embed presentation logic into presentation data.
690
- In Kwartz, 'title' attributes<sup>(<a href="#fnref:4" name="fnlink:4">*4</a>)</sup> are used to describe directives.
708
+ In Kwartz, 'kw:d' attributes<sup>(<a href="#fnref:4" name="fnlink:4">*4</a>)</sup> are used to describe directives.
691
709
  </p>
692
710
  <p>The following is an example to use directives.
693
711
  </p>
694
712
  <ul type="disc">
695
- <li>Directive <code>title="for <i>var</i> in <i>list</i>"</code> means to iterate the element.
713
+ <li>Directive <code>kw:d="for <em>var</em> in <em>list</em>"</code> means to iterate the element.
696
714
  </li>
697
- <li>Directive <code>title="value: <i>expression</i>"</code> means to print value of expression as content of the element.
715
+ <li>Directive <code>kw:d="value: <em>expression</em>"</code> means to print value of expression as content of the element.
698
716
  </li>
699
- <li>Directive <code>title="dummy:"</code> means that the element is a dummy and is not printed out.
717
+ <li>Directive <code>kw:d="dummy:"</code> means that the element is a dummy and is not printed out.
700
718
  </li>
701
719
  </ul>
702
720
  <a name="directive1.html"></a>
703
721
  <div class="program_caption">
704
722
  Presentation Data(directive1.html):</div>
705
723
  <pre class="program">&lt;table&gt;
706
- &lt;tr <b>title="for member in @members"</b>&gt;
707
- &lt;td <b>title="value: member.name"</b>&gt;foo&lt;/td&gt;
724
+ &lt;tr <strong>kw:d="for member in @members"</strong>&gt;
725
+ &lt;td <strong>kw:d="value: member.name"</strong>&gt;foo&lt;/td&gt;
708
726
  &lt;td&gt;
709
727
  &lt;a href="mailto:&lt;%= member.email %&gt;"
710
- title="<b>value: member.email</b>"&gt;foo@mai.com&lt;/a&gt;
728
+ kw:d="<strong>value: member.email</strong>"&gt;foo@mai.com&lt;/a&gt;
711
729
  &lt;/td&gt;
712
730
  &lt;/tr&gt;
713
- &lt;tr <b>title="dummy:"</b>&gt;
731
+ &lt;tr <strong>kw:d="dummy:"</strong>&gt;
714
732
  &lt;td&gt;bar&lt;/td&gt;
715
733
  &lt;td&gt;&lt;a href="mailto:bar@mail.org"&gt;bar@mail.org&lt;/a&gt;&lt;/td&gt;
716
734
  &lt;/tr&gt;
717
- &lt;tr <b>title="dummy:"</b>&gt;
735
+ &lt;tr <strong>kw:d="dummy:"</strong>&gt;
718
736
  &lt;td&gt;baz&lt;/td&gt;
719
737
  &lt;td&gt;&lt;a href="mailto:baz@mail.net"&gt;baz@mail.net&lt;/a&gt;&lt;/td&gt;
720
738
  &lt;/tr&gt;
@@ -728,14 +746,14 @@ Compile:</div>
728
746
  <div class="program_caption">
729
747
  Output script:</div>
730
748
  <pre class="program">&lt;table&gt;
731
- <b>&lt;% for member in @members do %&gt;</b>
749
+ <strong>&lt;% for member in @members do %&gt;</strong>
732
750
  &lt;tr&gt;
733
- &lt;td&gt;<b>&lt;%= member.name %&gt;</b>&lt;/td&gt;
751
+ &lt;td&gt;<strong>&lt;%= member.name %&gt;</strong>&lt;/td&gt;
734
752
  &lt;td&gt;
735
- &lt;a href="mailto:<b>&lt;%= member.email %&gt;</b>"&gt;<b>&lt;%= member.email %&gt;</b>&lt;/a&gt;
753
+ &lt;a href="mailto:<strong>&lt;%= member.email %&gt;</strong>"&gt;<strong>&lt;%= member.email %&gt;</strong>&lt;/a&gt;
736
754
  &lt;/td&gt;
737
755
  &lt;/tr&gt;
738
- <b>&lt;% end %&gt;</b>
756
+ <strong>&lt;% end %&gt;</strong>
739
757
  &lt;/table&gt;
740
758
  </pre>
741
759
  <p>If the first character of target attribute is a space, Kwartz recognize it as non-directive<sup>(<a href="#fnref:5" name="fnlink:5">*5</a>)</sup>.
@@ -743,15 +761,15 @@ Output script:</div>
743
761
  <a name="directive2.html"></a>
744
762
  <div class="program_caption">
745
763
  presentation data (directive2.html)</div>
746
- <pre class="program">&lt;span <b>title="value: expr1"</b>&gt;foo&lt;/span&gt;
747
- &lt;span <b>title=" value: expr2"</b>&gt;bar&lt;/span&gt;
764
+ <pre class="program">&lt;span <strong>kw:d="value: expr1"</strong>&gt;foo&lt;/span&gt;
765
+ &lt;span <strong>kw:d=" value: expr2"</strong>&gt;bar&lt;/span&gt;
748
766
  </pre>
749
767
  <a name="directive2.expected"></a>
750
768
  <div class="terminal_caption">
751
769
  compile</div>
752
770
  <pre class="terminal">$ kwartz directive2.html
753
- &lt;span&gt;<b>&lt;%= expr1 %&gt;</b>&lt;/span&gt;
754
- &lt;span <b>title="value: expr2"</b>&gt;bar&lt;/span&gt;
771
+ &lt;span&gt;<strong>&lt;%= expr1 %&gt;</strong>&lt;/span&gt;
772
+ &lt;span <strong>kw:d="value: expr2"</strong>&gt;bar&lt;/span&gt;
755
773
  </pre>
756
774
  <p>Directives are different in each target language.
757
775
  For example, foreach loop is 'for item in list' in eRuby, 'foreach($list as $item)' in PHP, 'forEach(item in list)' in JSTL.
@@ -768,22 +786,73 @@ See reference manual for details about directives.
768
786
  <br>
769
787
 
770
788
 
789
+ <a name="embed_expr"></a>
790
+ <h3 class="section2">Embed Expression in Presentation Data</h3>
791
+ <p>It is able to embed expressions in presentation data file in each language format.
792
+ For example, you can use '&lt;%= ... %&gt;' with eRuby, '#{...}' with Ruby, '&lt;?php echo ... ?&gt;' with PHP, and so on.
793
+ </p>
794
+ <p>(Experimental) '@{...}@' and '@!{...}@' are also available as embedded expression notation in all languages.
795
+ The former escapes expression and the latter does not escape expression.
796
+ </p>
797
+ <a name="embed1_eruby.html"></a>
798
+ <div class="program_caption">
799
+ presentation data (embed1_eruby.html)</div>
800
+ <pre class="program">&lt;p class="<strong>&lt;%= klass %&gt;</strong>"&gt;Hello <strong>&lt;%=h user %&gt;</strong>&lt;/p&gt;
801
+ &lt;p class="<strong>@!{klass}@</strong>"&gt;Hello <strong>@{user}@</strong>&lt;/p&gt;
802
+ </pre>
803
+ <a name="embed1_eruby.expected"></a>
804
+ <div class="terminal_caption">
805
+ compile</div>
806
+ <pre class="terminal">$ kwartz -l eruby embed1_eruby.html
807
+ &lt;p class="<strong>&lt;%= klass %&gt;</strong>"&gt;Hello <strong>&lt;%=h user %&gt;</strong>&lt;/p&gt;
808
+ &lt;p class="<strong>&lt;%= klass %&gt;</strong>"&gt;Hello <strong>&lt;%=h user %&gt;</strong>&lt;/p&gt;
809
+ </pre>
810
+ <a name="embed1_ruby.html"></a>
811
+ <div class="program_caption">
812
+ presentation data (embed1_ruby.html)</div>
813
+ <pre class="program">&lt;p class="<strong>#{klass}</strong>"&gt;Hello <strong>#{ERB::Util.h user}</strong>&lt;/p&gt;
814
+ &lt;p class="<strong>@!{klass}@</strong>"&gt;Hello <strong>@{user}@</strong>&lt;/p&gt;
815
+ </pre>
816
+ <a name="embed1_ruby.expected"></a>
817
+ <div class="terminal_caption">
818
+ compile</div>
819
+ <pre class="terminal">$ kwartz -l eruby embed1_ruby.html
820
+ _buf = ""; _buf &lt;&lt; "&lt;p class=\"<strong>#{klass}</strong>\"&gt;Hello <strong>#{ERB::Util.h user}</strong>&lt;/p&gt;
821
+ &lt;p class=\""; _buf &lt;&lt; <strong>(klass).to_s</strong>; _buf &lt;&lt; "\"&gt;Hello "; _buf &lt;&lt; <strong>ERB::Util.h(user)</strong>; _buf &lt;&lt; "&lt;/p&gt;\n";
822
+ ; _buf
823
+ </pre>
824
+ <a name="embed1_php.html"></a>
825
+ <div class="program_caption">
826
+ presentation data (embed1_php.html)</div>
827
+ <pre class="program">&lt;p class="<strong>&lt;?php echo $klass; ?&gt;</strong>"&gt;Hello <strong>&lt;?php echo htmlspecialchars($user); ?&gt;</strong>&lt;/p&gt;
828
+ &lt;p class="<strong>@!{$klass}@</strong>"&gt;Hello <strong>@{$user}@</strong>&lt;/p&gt;
829
+ </pre>
830
+ <a name="embed1_php.expected"></a>
831
+ <div class="terminal_caption">
832
+ compile</div>
833
+ <pre class="terminal">$ kwartz -l eruby embed1_php.html
834
+ &lt;p class="<strong>&lt;?php echo $klass; ?&gt;</strong>"&gt;Hello <strong>&lt;?php echo htmlspecialchars($user); ?&gt;</strong>&lt;/p&gt;
835
+ &lt;p class="<strong>&lt;?php echo $klass; ?&gt;</strong>"&gt;Hello <strong>&lt;?php echo htmlspecialchars($user); ?&gt;</strong>&lt;/p&gt;
836
+ </pre>
837
+ <br>
838
+
839
+
771
840
  <a name="escape"></a>
772
841
  <h3 class="section2">Escape</h3>
773
842
  <p>Kwartz supports Automatic-escape and Partial-escape/unescape.
774
843
  </p>
775
844
  <ul type="disc">
776
- <li>If command-line option '<code>-e</code>' is specified, values of '<code>value: <i>expr</i></code>'
845
+ <li>If command-line option '<code>-e</code>' is specified, values of '<code>value: <em>expr</em></code>'
777
846
  are escaped. (Automatic-escape)
778
847
  </li>
779
- <li>'<code>Value: <i>expr</i></code>' always escapes value even when '<code>-e</code>' is not specified. (Partial-escape)
848
+ <li>'<code>Value: <em>expr</em></code>' always escapes value even when '<code>-e</code>' is not specified. (Partial-escape)
780
849
  </li>
781
- <li>'<code>VALUE: <i>expr</i></code>' always doesn't escapes value even when '<code>-e</code>' is specified. (Partial-unescape)
850
+ <li>'<code>VALUE: <em>expr</em></code>' always doesn't escapes value even when '<code>-e</code>' is specified. (Partial-unescape)
782
851
  </li>
783
852
  </ul>
784
853
  <a name="escape1.html"></a>
785
854
  <div class="program_caption">
786
- presentation Data (escape1.html):</div>
855
+ presentation data (escape1.html):</div>
787
856
  <pre class="program">&lt;tr&gt;
788
857
  &lt;td id="mark:val1"&gt;foo&lt;/td&gt;
789
858
  &lt;td id="mark:val2"&gt;bar&lt;/td&gt;
@@ -794,13 +863,13 @@ presentation Data (escape1.html):</div>
794
863
  <div class="program_caption">
795
864
  presentation logic (escape1.plogic)</div>
796
865
  <pre class="program">#val1 {
797
- <b>value:</b> expr;
866
+ <strong>value:</strong> expr;
798
867
  }
799
868
  #val2 {
800
- <b>Value:</b> expr;
869
+ <strong>Value:</strong> expr;
801
870
  }
802
871
  #val3 {
803
- <b>VALUE:</b> expr;
872
+ <strong>VALUE:</strong> expr;
804
873
  }
805
874
  </pre>
806
875
  <a name="escape1.expected"></a>
@@ -816,11 +885,11 @@ compile without '<code>-e</code>' option.</div>
816
885
  <a name="escape1e.expected"></a>
817
886
  <div class="terminal_caption">
818
887
  comple with '<code>-e</code>' option.</div>
819
- <pre class="terminal">$ kwartz <b>-e</b> -p escape1.plogic escape1.html
888
+ <pre class="terminal">$ kwartz <strong>-e</strong> -p escape1.plogic escape1.html
820
889
  &lt;tr&gt;
821
- &lt;td&gt;<b>&lt;%=h expr %&gt;</b>&lt;/td&gt;
822
- &lt;td&gt;<b>&lt;%=h expr %&gt;</b>&lt;/td&gt;
823
- &lt;td&gt;<b>&lt;%= expr %&gt;</b>&lt;/td&gt;
890
+ &lt;td&gt;<strong>&lt;%=h expr %&gt;</strong>&lt;/td&gt;
891
+ &lt;td&gt;<strong>&lt;%=h expr %&gt;</strong>&lt;/td&gt;
892
+ &lt;td&gt;<strong>&lt;%= expr %&gt;</strong>&lt;/td&gt;
824
893
  &lt;/tr&gt;
825
894
  </pre>
826
895
  <p>In the same way, '<code>Stag:</code>', '<code>Etag:</code>', '<code>Elem:</code>',
@@ -833,9 +902,9 @@ never escaped.
833
902
  'h()' is used in eRuby and 'htmlspecialchars()' in PHP.
834
903
  JSTL prints escaped value in default.
835
904
  </p>
836
- <p>Directives <code>title="Value: <i>expr</i>"</code>, <code>title="Attr: '<i>name</i>' <i>expr</i>"</code>, and <code>title="Append: <i>expr</i>"</code> always escape expression value even when the command-line option '<code>-e</code>' is not specified.
905
+ <p>Directives <code>kw:d="Value: <em>expr</em>"</code>, <code>kw:d="Attr: '<em>name</em>' <em>expr</em>"</code>, and <code>kw:d="Append: <em>expr</em>"</code> always escape expression value even when the command-line option '<code>-e</code>' is not specified.
837
906
  </p>
838
- <p>Directives <code>title="VALUE: <i>expr</i>:"</code>, <code>title="ATTR: '<i>name</i>' <i>expr</i>"</code>, and <code>title="APPEND: <i>expr</i>"</code> doesn't escape expression value even when the command-line option '<code>-e</code>' is specified.
907
+ <p>Directives <code>kw:d="VALUE: <em>expr</em>:"</code>, <code>kw:d="ATTR: '<em>name</em>' <em>expr</em>"</code>, and <code>kw:d="APPEND: <em>expr</em>"</code> doesn't escape expression value even when the command-line option '<code>-e</code>' is specified.
839
908
  </p>
840
909
  <p>Configuration option PROPERTY_ESCAPE in 'kwartz/config.rb' determines whether values are escaped or not in default.
841
910
  If this is true then Kwartz will escape values in default.
@@ -848,20 +917,20 @@ If this is true then Kwartz will escape values in default.
848
917
  <p>Kwartz-ruby now supports the following programming language.
849
918
  </p>
850
919
  <ul type="disc">
851
- <li>Ruby (eRuby)
920
+ <li>Ruby, eRuby(ERB, Erubis)
852
921
  </li>
853
922
  <li>PHP
854
923
  </li>
855
924
  <li>JSP (JSTL 1.1 and 1.2)
856
925
  </li>
857
- <li>Perl (ePerl) [experimental]
926
+ <li>ePerl [experimental]
858
927
  </li>
859
928
  </ul>
860
929
  <p>Presentation logics must be described in each target language.
861
930
  It means that if you have wrote presentation logics in Ruby, they were not reusable
862
931
  for PHP project (but you can get full-power of Ruby in presentation logic).
863
932
  </p>
864
- <p>The followings are examples of Ruby, PHP, JSP, and Perl.
933
+ <p>The followings are examples of Ruby, eRuby, PHP, JSP, and ePerl.
865
934
  </p>
866
935
  <a name="table1.html"></a>
867
936
  <div class="program_caption">
@@ -870,15 +939,15 @@ table1.html</div>
870
939
  &lt;body&gt;
871
940
 
872
941
  &lt;table&gt;
873
- &lt;tr bgcolor="#CCCCFF" <b>id="mark:row"</b>&gt;
874
- &lt;td <b>id="mark:name"</b>&gt;Foo&lt;/td&gt;
875
- &lt;td <b>id="mark:mail"</b>&gt;foo@mail.com&lt;/td&gt;
942
+ &lt;tr bgcolor="#CCCCFF" <strong>id="mark:row"</strong>&gt;
943
+ &lt;td <strong>id="mark:name"</strong>&gt;Foo&lt;/td&gt;
944
+ &lt;td <strong>id="mark:mail"</strong>&gt;foo@mail.com&lt;/td&gt;
876
945
  &lt;/tr&gt;
877
- &lt;tr bgcolor="#FFCCCC" <b>id="dummy:row1"</b>&gt;
946
+ &lt;tr bgcolor="#FFCCCC" <strong>id="dummy:row1"</strong>&gt;
878
947
  &lt;td&gt;Bar&lt;/td&gt;
879
948
  &lt;td&gt;bar@mail.net&lt;/td&gt;
880
949
  &lt;/tr&gt;
881
- &lt;tr bgcolor="#CCCCFF" <b>id="dummy:row2"</b>&gt;
950
+ &lt;tr bgcolor="#CCCCFF" <strong>id="dummy:row2"</strong>&gt;
882
951
  &lt;td&gt;Baz&lt;/td&gt;
883
952
  &lt;td&gt;baz@mail.org&lt;/td&gt;
884
953
  &lt;/tr&gt;
@@ -887,16 +956,16 @@ table1.html</div>
887
956
  &lt;/body&gt;
888
957
  &lt;/html&gt;
889
958
  </pre>
890
- <a name="table1.eruby.plogic"></a>
959
+ <a name="table1.ruby.plogic"></a>
891
960
  <div class="program_caption">
892
- table1.eruby.plogic</div>
961
+ table1.ruby.plogic</div>
893
962
  <pre class="program">#row {
894
963
  attrs: "bgcolor" color;
895
964
  logic: {
896
965
  @list.each_with_index do |user, i|
897
- color = i % 2 == 1 ? '#FFCCCC' : '#CCCCFF';
966
+ color = i % 2 == 1 ? '#FFCCCC' : '#CCCCFF'
898
967
  _elem
899
- }
968
+ end
900
969
  }
901
970
  }
902
971
 
@@ -975,25 +1044,85 @@ table1.eperl.plogic</div>
975
1044
  </pre>
976
1045
  <div class="terminal_caption">
977
1046
  compile</div>
978
- <pre class="terminal">$ kwartz -l eruby -p table1.eruby.plogic table1.html &gt; table1.rhtml
979
- $ kwartz -l php -p table1.php.plogic table1.html &gt; table1.php
980
- $ kwartz -l jstl -p table1.jstl.plogic table1.html &gt; table1.jsp
981
- $ kwartz -l eperl -p table1.eperl.plogic table1.html &gt; table1.iphtml
1047
+ <pre class="terminal">$ kwartz -l eruby -p table1.ruby.plogic table1.html &gt; table1.eruby
1048
+ $ kwartz -l ruby -p table1.ruby.plogic table1.html &gt; table1.rb
1049
+ $ kwartz -l pierubis -p table1.ruby.plogic table1.html &gt; table1.pierubis
1050
+ $ kwartz -l php -p table1.php.plogic table1.html &gt; table1.php
1051
+ $ kwartz -l jstl -p table1.jstl.plogic table1.html &gt; table1.jsp
1052
+ $ kwartz -l eperl -p table1.eperl.plogic table1.html &gt; table1.eperl
1053
+ </pre>
1054
+ <a name="table1.eruby"></a>
1055
+ <div class="program_caption">
1056
+ output script (table1.eruby)</div>
1057
+ <pre class="program">&lt;html&gt;
1058
+ &lt;body&gt;
1059
+
1060
+ &lt;table&gt;
1061
+ <strong>&lt;% @list.each_with_index do |user, i| %&gt;</strong>
1062
+ <strong>&lt;% color = i % 2 == 1 ? '#FFCCCC' : '#CCCCFF' %&gt;</strong>
1063
+ &lt;tr bgcolor="<strong>&lt;%= color %&gt;</strong>"&gt;
1064
+ &lt;td&gt;<strong>&lt;%=h user[:name] %&gt;</strong>&lt;/td&gt;
1065
+ &lt;td&gt;<strong>&lt;%= user[:mail] %&gt;</strong>&lt;/td&gt;
1066
+ &lt;/tr&gt;
1067
+ <strong>&lt;% end %&gt;</strong>
1068
+ &lt;/table&gt;
1069
+
1070
+ &lt;/body&gt;
1071
+ &lt;/html&gt;
1072
+ </pre>
1073
+ <a name="table1.rb"></a>
1074
+ <div class="program_caption">
1075
+ output script (table1.rb)</div>
1076
+ <pre class="program">_buf = ""; _buf &lt;&lt; "&lt;html&gt;
1077
+ &lt;body&gt;
1078
+
1079
+ &lt;table&gt;\n";
1080
+ <strong>@list.each_with_index do |user, i|</strong>
1081
+ <strong>color = i % 2 == 1 ? '#FFCCCC' : '#CCCCFF'</strong>
1082
+ _buf &lt;&lt; " &lt;tr bgcolor=\""; _buf &lt;&lt; (color).to_s; _buf &lt;&lt; "\"&gt;
1083
+ &lt;td&gt;"; <strong>_buf &lt;&lt; ERB::Util.h(user[:name]);</strong> _buf &lt;&lt; "&lt;/td&gt;
1084
+ &lt;td&gt;"; <strong>_buf &lt;&lt; (user[:mail]).to_s;</strong> _buf &lt;&lt; "&lt;/td&gt;
1085
+ &lt;/tr&gt;\n";
1086
+ <strong>end</strong>
1087
+ _buf &lt;&lt; " &lt;/table&gt;
1088
+
1089
+ &lt;/body&gt;
1090
+ &lt;/html&gt;\n";
1091
+ ; _buf
982
1092
  </pre>
983
- <a name="table1.rhtml"></a>
1093
+ <a name="table1.rails"></a>
984
1094
  <div class="program_caption">
985
- output script (table1.rhtml)</div>
1095
+ output script (table1.rails)</div>
986
1096
  <pre class="program">&lt;html&gt;
987
1097
  &lt;body&gt;
988
1098
 
989
1099
  &lt;table&gt;
990
- <b>&lt;% @list.each_with_index do |user, i| %&gt;</b>
991
- <b>&lt;% color = i % 2 == 1 ? '#FFCCCC' : '#CCCCFF' %&gt;</b>
992
- &lt;tr bgcolor="<b>&lt;%= color %&gt;</b>"&gt;
993
- &lt;td&gt;<b>&lt;%=h user[:name] %&gt;</b>&lt;/td&gt;
994
- &lt;td&gt;<b>&lt;%= user[:mail] %&gt;</b>&lt;/td&gt;
1100
+ <strong>&lt;% @list.each_with_index do |user, i| -%&gt;</strong>
1101
+ <strong>&lt;% color = i % 2 == 1 ? '#FFCCCC' : '#CCCCFF' -%&gt;</strong>
1102
+ &lt;tr bgcolor="<strong>&lt;%= color %&gt;</strong>"&gt;
1103
+ &lt;td&gt;<strong>&lt;%=h user[:name] %&gt;</strong>&lt;/td&gt;
1104
+ &lt;td&gt;<strong>&lt;%= user[:mail] %&gt;</strong>&lt;/td&gt;
995
1105
  &lt;/tr&gt;
996
- <b>&lt;% end %&gt;</b>
1106
+ <strong>&lt;% end -%&gt;</strong>
1107
+ &lt;/table&gt;
1108
+
1109
+ &lt;/body&gt;
1110
+ &lt;/html&gt;
1111
+ </pre>
1112
+ <a name="table1.pierubis"></a>
1113
+ <div class="program_caption">
1114
+ output script (table1.pierubis)</div>
1115
+ <pre class="program">&lt;html&gt;
1116
+ &lt;body&gt;
1117
+
1118
+ &lt;table&gt;
1119
+ <strong>&lt;?rb @list.each_with_index do |user, i| ?&gt;</strong>
1120
+ <strong>&lt;?rb color = i % 2 == 1 ? '#FFCCCC' : '#CCCCFF' ?&gt;</strong>
1121
+ &lt;tr bgcolor="<strong>@!{color}@</strong>"&gt;
1122
+ &lt;td&gt;<strong>@{user[:name]}@</strong>&lt;/td&gt;
1123
+ &lt;td&gt;<strong>@!{user[:mail]}@</strong>&lt;/td&gt;
1124
+ &lt;/tr&gt;
1125
+ <strong>&lt;?rb end ?&gt;</strong>
997
1126
  &lt;/table&gt;
998
1127
 
999
1128
  &lt;/body&gt;
@@ -1006,14 +1135,14 @@ output script (table1.php)</div>
1006
1135
  &lt;body&gt;
1007
1136
 
1008
1137
  &lt;table&gt;
1009
- <b>&lt;?php $i = 0; ?&gt;</b>
1010
- <b>&lt;?php foreach ($list as $user) { ?&gt;</b>
1011
- <b>&lt;?php $color = ++$i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'; ?&gt;</b>
1012
- &lt;tr bgcolor="<b>&lt;?php echo $color; ?&gt;</b>"&gt;
1013
- &lt;td&gt;<b>&lt;?php echo htmlspecialchars($user['name']); ?&gt;</b>&lt;/td&gt;
1014
- &lt;td&gt;<b>&lt;?php echo $user['mail']; ?&gt;</b>&lt;/td&gt;
1138
+ <strong>&lt;?php $i = 0; ?&gt;</strong>
1139
+ <strong>&lt;?php foreach ($list as $user) { ?&gt;</strong>
1140
+ <strong>&lt;?php $color = ++$i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'; ?&gt;</strong>
1141
+ &lt;tr bgcolor="<strong>&lt;?php echo $color; ?&gt;</strong>"&gt;
1142
+ &lt;td&gt;<strong>&lt;?php echo htmlspecialchars($user['name']); ?&gt;</strong>&lt;/td&gt;
1143
+ &lt;td&gt;<strong>&lt;?php echo $user['mail']; ?&gt;</strong>&lt;/td&gt;
1015
1144
  &lt;/tr&gt;
1016
- <b>&lt;?php } ?&gt;</b>
1145
+ <strong>&lt;?php } ?&gt;</strong>
1017
1146
  &lt;/table&gt;
1018
1147
 
1019
1148
  &lt;/body&gt;
@@ -1028,33 +1157,33 @@ output script (JSTL 1.2)</div>
1028
1157
  &lt;body&gt;
1029
1158
 
1030
1159
  &lt;table&gt;
1031
- <b>&lt;c:forEach var="user" items="${list}" varStatus="loop"&gt;</b>
1032
- <b>&lt;c:set var="color" value="${loop.index % 2 == 0 ? '#FFCCCC' : '#CCCCFF'}"/&gt;</b>
1033
- &lt;tr bgcolor="<b>${color}</b>"&gt;
1034
- &lt;td&gt;<b>${user.name}</b>&lt;/td&gt;
1035
- &lt;td&gt;<b>${user.mail}</b>&lt;/td&gt;
1160
+ <strong>&lt;c:forEach var="user" items="${list}" varStatus="loop"&gt;</strong>
1161
+ <strong>&lt;c:set var="color" value="${loop.index % 2 == 0 ? '#FFCCCC' : '#CCCCFF'}"/&gt;</strong>
1162
+ &lt;tr bgcolor="<strong>${color}</strong>"&gt;
1163
+ &lt;td&gt;<strong>${user.name}</strong>&lt;/td&gt;
1164
+ &lt;td&gt;<strong>${user.mail}</strong>&lt;/td&gt;
1036
1165
  &lt;/tr&gt;
1037
- <b>&lt;/c:forEach&gt;</b>
1166
+ <strong>&lt;/c:forEach&gt;</strong>
1038
1167
  &lt;/table&gt;
1039
1168
 
1040
1169
  &lt;/body&gt;
1041
1170
  &lt;/html&gt;
1042
1171
  </pre>
1043
- <a name="table1.iphtml"></a>
1172
+ <a name="table1.eperl"></a>
1044
1173
  <div class="program_caption">
1045
1174
  output script (ePerl)</div>
1046
1175
  <pre class="program">&lt;html&gt;
1047
1176
  &lt;body&gt;
1048
1177
 
1049
1178
  &lt;table&gt;
1050
- <b>&lt;? $i = 0; !&gt;</b>
1051
- <b>&lt;? foreach ($user in @list) { !&gt;</b>
1052
- <b>&lt;? $color = ++$i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'; !&gt;</b>
1053
- &lt;tr bgcolor="<b>&lt;?= $color !&gt;</b>"&gt;
1054
- &lt;td&gt;<b>&lt;?= encode_entities($user{'name'}) !&gt;</b>&lt;/td&gt;
1055
- &lt;td&gt;<b>&lt;?= $user{'mail'} !&gt;</b>&lt;/td&gt;
1179
+ <strong>&lt;? $i = 0; !&gt;</strong>
1180
+ <strong>&lt;? foreach ($user in @list) { !&gt;</strong>
1181
+ <strong>&lt;? $color = ++$i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'; !&gt;</strong>
1182
+ &lt;tr bgcolor="<strong>&lt;?= $color !&gt;</strong>"&gt;
1183
+ &lt;td&gt;<strong>&lt;?= encode_entities($user{'name'}) !&gt;</strong>&lt;/td&gt;
1184
+ &lt;td&gt;<strong>&lt;?= $user{'mail'} !&gt;</strong>&lt;/td&gt;
1056
1185
  &lt;/tr&gt;
1057
- <b>&lt;? } !&gt;</b>
1186
+ <strong>&lt;? } !&gt;</strong>
1058
1187
  &lt;/table&gt;
1059
1188
 
1060
1189
  &lt;/body&gt;
@@ -1070,9 +1199,9 @@ output script (ePerl)</div>
1070
1199
  <a name="delspan1.html"></a>
1071
1200
  <div class="program_caption">
1072
1201
  presentation data (delspan1.html)</div>
1073
- <pre class="program">&lt;h1&gt;&lt;span <b>id="mark:title"</b>&gt;title&lt;/span&gt;&lt;/h1&gt;
1202
+ <pre class="program">&lt;h1&gt;&lt;span <strong>id="mark:title"</strong>&gt;title&lt;/span&gt;&lt;/h1&gt;
1074
1203
 
1075
- Hello &lt;span <b>title="value: user"</b>&gt;World&lt;/span&gt;!
1204
+ Hello &lt;span <strong>kw:d="value: user"</strong>&gt;World&lt;/span&gt;!
1076
1205
  </pre>
1077
1206
  <a name="delspan1.plogic"></a>
1078
1207
  <div class="program_caption">
@@ -1084,23 +1213,23 @@ presentation logic (delspan1.plogic)</div>
1084
1213
  <a name="delspan1.expected"></a>
1085
1214
  <div class="terminal_caption">
1086
1215
  compile</div>
1087
- <pre class="terminal">$ kwartz -p delspan1.plogic <b>--delspan</b> delspan1.html
1088
- &lt;h1&gt;<b>&lt;%= title %&gt;</b>&lt;/h1&gt;
1216
+ <pre class="terminal">$ kwartz -p delspan1.plogic <strong>--delspan</strong> delspan1.html
1217
+ &lt;h1&gt;<strong>&lt;%= title %&gt;</strong>&lt;/h1&gt;
1089
1218
 
1090
- Hello <b>&lt;%= user %&gt;</b>!
1219
+ Hello <strong>&lt;%= user %&gt;</strong>!
1091
1220
  </pre>
1092
1221
  <p>The span tags are not removed when they have other attributes.
1093
1222
  </p>
1094
1223
  <a name="delspan2.html"></a>
1095
1224
  <div class="program_caption">
1096
1225
  presentation data (delspan2.html)</div>
1097
- <pre class="program">Hello &lt;span <b>title="value: user" style="color:black"</b>&gt;World&lt;/span&gt;!
1226
+ <pre class="program">Hello &lt;span <strong>kw:d="value: user" style="color:black"</strong>&gt;World&lt;/span&gt;!
1098
1227
  </pre>
1099
1228
  <a name="delspan2.expected"></a>
1100
1229
  <div class="terminal_caption">
1101
1230
  compile</div>
1102
- <pre class="terminal">$ kwartz <b>--delspan</b> delspan2.html
1103
- Hello <b>&lt;span style="color:black"&gt;</b>&lt;%= user %&gt;<b>&lt;/span&gt;</b>!
1231
+ <pre class="terminal">$ kwartz <strong>--delspan</strong> delspan2.html
1232
+ Hello <strong>&lt;span style="color:black"&gt;</strong>&lt;%= user %&gt;<strong>&lt;/span&gt;</strong>!
1104
1233
  </pre>
1105
1234
  <br>
1106
1235
 
@@ -1113,20 +1242,20 @@ This is useful to share common presentation logic in many files.
1113
1242
  <a name="link_to2.plogic"></a>
1114
1243
  <div class="program_caption">
1115
1244
  link_to.plogic</div>
1116
- <pre class="program"><b>#link_to_new</b> {
1117
- elem: start_link_to :action=&gt;'new';
1245
+ <pre class="program"><strong>#link_to_new</strong> {
1246
+ elem: start_link_tag :action=&gt;'new';
1118
1247
  }
1119
- <b>#link_to_show</b> {
1120
- elem: start_link_to :action=&gt;'show', :id=&gt;@member;
1248
+ <strong>#link_to_show</strong> {
1249
+ elem: start_link_tag :action=&gt;'show', :id=&gt;@member;
1121
1250
  }
1122
- <b>#link_to_edit</b> {
1123
- elem: start_link_to :action=&gt;'edit', :id=&gt;@member;
1251
+ <strong>#link_to_edit</strong> {
1252
+ elem: start_link_tag :action=&gt;'edit', :id=&gt;@member;
1124
1253
  }
1125
- <b>#link_to_list</b> {
1126
- elem: start_link_to :action=&gt;'list';
1254
+ <strong>#link_to_list</strong> {
1255
+ elem: start_link_tag :action=&gt;'list';
1127
1256
  }
1128
- <b>#link_to_destroy</b> {
1129
- stag: start_link_to({:action=&gt;'destroy', :id=&gt;@member}, :confirm=&gt;'Are you sure?');
1257
+ <strong>#link_to_destroy</strong> {
1258
+ stag: start_link_tag({:action=&gt;'destroy', :id=&gt;@member}, :confirm=&gt;'Are you sure?');
1130
1259
  }
1131
1260
  </pre>
1132
1261
  <a name="show2.html"></a>
@@ -1136,13 +1265,13 @@ show.html</div>
1136
1265
  Name: &lt;span id="mark:name"&gt;foo&lt;/span&gt; &lt;br&gt;
1137
1266
  Email: &lt;span id="mark:email"&gt;foo@mail.com&lt;/span&gt; &lt;br&gt;
1138
1267
  &lt;/p&gt;
1139
- &lt;a href="#" <b>id="link_to_edit"</b>&gt;Edit this member&lt;/a&gt; |
1140
- &lt;a href="#" <b>id="link_to_new"</b>&gt;Create new member&lt;/a&gt; |
1141
- &lt;a href="#" <b>id="link_to_list"</b>&gt;Return to list&lt;/a&gt;
1268
+ &lt;a href="#" <strong>id="link_to_edit"</strong>&gt;Edit this member&lt;/a&gt; |
1269
+ &lt;a href="#" <strong>id="link_to_new"</strong>&gt;Create new member&lt;/a&gt; |
1270
+ &lt;a href="#" <strong>id="link_to_list"</strong>&gt;Return to list&lt;/a&gt;
1142
1271
  </pre>
1143
1272
  <div class="program_caption">
1144
1273
  show.plogic</div>
1145
- <pre class="program"><b>@import 'link_to.plogic';</b>
1274
+ <pre class="program"><strong>@import 'link_to.plogic';</strong>
1146
1275
 
1147
1276
  #name {
1148
1277
  Value: @member.name;
@@ -1159,24 +1288,24 @@ compile</div>
1159
1288
  Name: &lt;span&gt;&lt;%=h @member.name %&gt;&lt;/span&gt; &lt;br&gt;
1160
1289
  Email: &lt;span&gt;&lt;%=h @member.email %&gt;&lt;/span&gt; &lt;br&gt;
1161
1290
  &lt;/p&gt;
1162
- &lt;%= start_link_to :action=&gt;'edit', :id=&gt;@member %&gt; |
1163
- &lt;%= start_link_to :action=&gt;'new' %&gt; |
1164
- &lt;%= start_link_to :action=&gt;'list' %&gt;
1291
+ &lt;%= start_link_tag :action=&gt;'edit', :id=&gt;@member %&gt; |
1292
+ &lt;%= start_link_tag :action=&gt;'new' %&gt; |
1293
+ &lt;%= start_link_tag :action=&gt;'list' %&gt;
1165
1294
  </pre>
1166
1295
  <br>
1167
1296
 
1168
1297
 
1169
1298
  <a name="import-elem"></a>
1170
1299
  <h3 class="section2">Import Elements in Other Files</h3>
1171
- <p>Command-line option '-i <i>filename,...</i>' imports element definitions form other files.
1300
+ <p>Command-line option '-i <em>filename,...</em>' imports element definitions form other files.
1172
1301
  </p>
1173
1302
  <a name="form.html"></a>
1174
1303
  <div class="program_caption">
1175
1304
  form.html</div>
1176
1305
  <pre class="program">&lt;form&gt;
1177
- &lt;div <b>id="mark:form_content"</b>&gt;
1178
- <b>Name: &lt;input type="text"&gt;&lt;br&gt;</b>
1179
- <b>Password: &lt;input type="password"&gt;&lt;br&gt;</b>
1306
+ &lt;div <strong>id="mark:form_content"</strong>&gt;
1307
+ <strong>Name: &lt;input type="text"&gt;&lt;br&gt;</strong>
1308
+ <strong>Password: &lt;input type="password"&gt;&lt;br&gt;</strong>
1180
1309
  &lt;/div&gt;
1181
1310
  &lt;input type="submit"&gt;
1182
1311
  &lt;/form&gt;
@@ -1185,7 +1314,7 @@ form.html</div>
1185
1314
  <div class="program_caption">
1186
1315
  new.html</div>
1187
1316
  <pre class="program">&lt;form action="/new"&gt;
1188
- &lt;div <b>id="mark:placeholder"</b>&gt;&lt;/div&gt;
1317
+ &lt;div <strong>id="mark:placeholder"</strong>&gt;&lt;/div&gt;
1189
1318
  &lt;input type="submit" value="Create"&gt;
1190
1319
  &lt;/form&gt;
1191
1320
  </pre>
@@ -1193,19 +1322,19 @@ new.html</div>
1193
1322
  <div class="program_caption">
1194
1323
  new.plogic</div>
1195
1324
  <pre class="program">/* use element which is defined other file */
1196
- <b>#placeholder</b> {
1325
+ <strong>#placeholder</strong> {
1197
1326
  logic: {
1198
- <b>_content(form_content)</b>
1327
+ <strong>_content(form_content)</strong>
1199
1328
  }
1200
1329
  }
1201
1330
  </pre>
1202
1331
  <a name="new.expected"></a>
1203
1332
  <div class="terminal_caption">
1204
1333
  compile</div>
1205
- <pre class="terminal">$ kwartz <b>-i form.html</b> -p new.plogic new.html
1334
+ <pre class="terminal">$ kwartz <strong>-i form.html</strong> -p new.plogic new.html
1206
1335
  &lt;form action="/new"&gt;
1207
- <b>Name: &lt;input type="text"&gt;&lt;br&gt;</b>
1208
- <b>Password: &lt;input type="password"&gt;&lt;br&gt;</b>
1336
+ <strong>Name: &lt;input type="text"&gt;&lt;br&gt;</strong>
1337
+ <strong>Password: &lt;input type="password"&gt;&lt;br&gt;</strong>
1209
1338
  &lt;input type="submit" value="Create"&gt;
1210
1339
  &lt;/form&gt;
1211
1340
  </pre>
@@ -1214,15 +1343,15 @@ compile</div>
1214
1343
 
1215
1344
  <a name="extract"></a>
1216
1345
  <h3 class="section2">Extract Element</h3>
1217
- <p>Command option '-X <i>name</i>' extracts element marked as <i>name</i>
1218
- and command option '-x <i>name</i>' extracts content of element.
1346
+ <p>Command option '-X <em>name</em>' extracts element marked as <em>name</em>
1347
+ and command option '-x <em>name</em>' extracts content of element.
1219
1348
  </p>
1220
1349
  <a name="show.html"></a>
1221
1350
  <div class="program_caption">
1222
1351
  show.html</div>
1223
1352
  <pre class="program">&lt;html&gt;
1224
1353
  &lt;body&gt;
1225
- &lt;div <b>id="mark:content"</b>&gt;
1354
+ &lt;div <strong>id="mark:content"</strong>&gt;
1226
1355
  &lt;h1&gt;Show&lt;/h1&gt;
1227
1356
  &lt;p&gt;Name: &lt;span id="mark:name"&gt;foo&lt;/span&gt;&lt;/p&gt;
1228
1357
  &lt;p&gt;Email: &lt;span id="mark:email"&gt;foo@mail.com&lt;/span&gt;&lt;/p&gt;
@@ -1242,7 +1371,7 @@ show.plogic</div>
1242
1371
  </pre>
1243
1372
  <div class="terminal_caption">
1244
1373
  compile with '-X'</div>
1245
- <pre class="terminal">$ kwartz <b>-X content</b> -p show.plogic show.html
1374
+ <pre class="terminal">$ kwartz <strong>-X content</strong> -p show.plogic show.html
1246
1375
  &lt;div&gt;
1247
1376
  &lt;h1&gt;Show&lt;/h1&gt;
1248
1377
  &lt;p&gt;Name: &lt;span&gt;&lt;%= user.name %&gt;&lt;/span&gt;&lt;/p&gt;
@@ -1252,7 +1381,7 @@ compile with '-X'</div>
1252
1381
  <a name="test_show_cont.expected"></a>
1253
1382
  <div class="terminal_caption">
1254
1383
  compile with '-x'</div>
1255
- <pre class="terminal">$ kwartz <b>-x content</b> -p show.plogic show.html
1384
+ <pre class="terminal">$ kwartz <strong>-x content</strong> -p show.plogic show.html
1256
1385
  &lt;h1&gt;Show&lt;/h1&gt;
1257
1386
  &lt;p&gt;Name: &lt;span&gt;&lt;%= user.name %&gt;&lt;/span&gt;&lt;/p&gt;
1258
1387
  &lt;p&gt;Email: &lt;span&gt;&lt;%= user.email %&gt;&lt;/span&gt;&lt;/p&gt;
@@ -1278,7 +1407,7 @@ print-stmt.eruby.plogic</div>
1278
1407
  logic: {
1279
1408
  for item in list
1280
1409
  _stag
1281
- <b>print item</b>
1410
+ <strong>print item</strong>
1282
1411
  _etag
1283
1412
  end
1284
1413
  }
@@ -1290,7 +1419,7 @@ compile</div>
1290
1419
  <pre class="terminal">$ kwartz -l eruby -p print-stmt.eruby.plogic print-stmt.html
1291
1420
  &lt;ul&gt;
1292
1421
  &lt;% for item in list %&gt;
1293
- &lt;li id="items"&gt;<b>&lt;%= item %&gt;</b>&lt;/li&gt;
1422
+ &lt;li id="items"&gt;<strong>&lt;%= item %&gt;</strong>&lt;/li&gt;
1294
1423
  &lt;% end %&gt;
1295
1424
  &lt;/ul&gt;
1296
1425
  </pre>
@@ -1301,7 +1430,7 @@ print-stmt.php.plogic</div>
1301
1430
  logic: {
1302
1431
  foreach ($list as $item) {
1303
1432
  _stag();
1304
- <b>print($item);</b>
1433
+ <strong>print($item);</strong>
1305
1434
  _etag();
1306
1435
  }
1307
1436
  }
@@ -1313,7 +1442,7 @@ compile</div>
1313
1442
  <pre class="terminal">$ kwartz -l php -p print-stmt.php.plogic print-stmt.html
1314
1443
  &lt;ul&gt;
1315
1444
  &lt;?php foreach ($list as $item) { ?&gt;
1316
- &lt;li id="items"&gt;<b>&lt;?php echo $item; ?&gt;</b>&lt;/li&gt;
1445
+ &lt;li id="items"&gt;<strong>&lt;?php echo $item; ?&gt;</strong>&lt;/li&gt;
1317
1446
  &lt;?php } ?&gt;
1318
1447
  &lt;/ul&gt;
1319
1448
  </pre>
@@ -1324,7 +1453,7 @@ print-stmt.jstl.plogic</div>
1324
1453
  logic: {
1325
1454
  &lt;c:forEach var="item" items="${list}"&gt;
1326
1455
  _stag
1327
- <b>print item</b>
1456
+ <strong>print item</strong>
1328
1457
  _etag
1329
1458
  &lt;/c:forEach&gt;
1330
1459
  }
@@ -1338,7 +1467,7 @@ compile (JSTL 1.2)</div>
1338
1467
  &lt;%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %&gt;
1339
1468
  &lt;ul&gt;
1340
1469
  &lt;c:forEach var="item" items="${list}"&gt;
1341
- &lt;li id="items"&gt;<b>${item}</b>&lt;/li&gt;
1470
+ &lt;li id="items"&gt;<strong>${item}</strong>&lt;/li&gt;
1342
1471
  &lt;/c:forEach&gt;
1343
1472
  &lt;/ul&gt;
1344
1473
  </pre>
@@ -1349,7 +1478,7 @@ compile (JSTL 1.1)</div>
1349
1478
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %&gt;
1350
1479
  &lt;ul&gt;
1351
1480
  &lt;c:forEach var="item" items="${list}"&gt;
1352
- &lt;li id="items"&gt;<b>&lt;c:out value="${item}"/&gt;</b>&lt;/li&gt;
1481
+ &lt;li id="items"&gt;<strong>&lt;c:out value="${item}"/&gt;</strong>&lt;/li&gt;
1353
1482
  &lt;/c:forEach&gt;
1354
1483
  &lt;/ul&gt;
1355
1484
  </pre>
@@ -1374,12 +1503,12 @@ document-test.html</div>
1374
1503
  <a name="document-test.plogic"></a>
1375
1504
  <div class="program_caption">
1376
1505
  document-test.plogic</div>
1377
- <pre class="program"><b>#DOCUMENT</b> {
1378
- <b>begin:</b> {
1506
+ <pre class="program"><strong>#DOCUMENT</strong> {
1507
+ <strong>begin:</strong> {
1379
1508
  title = _context[:title]
1380
1509
  user = _context[:user]
1381
1510
  }
1382
- <b>end:</b> {
1511
+ <strong>end:</strong> {
1383
1512
  print "&lt;!--end--&gt;\n"
1384
1513
  }
1385
1514
  }
@@ -1388,12 +1517,368 @@ document-test.plogic</div>
1388
1517
  <div class="terminal_caption">
1389
1518
  compile</div>
1390
1519
  <pre class="terminal">$ kwartz -p document-test.plogic document-test.html
1391
- <b>&lt;% title = _context[:title] %&gt;</b>
1392
- <b>&lt;% user = _context[:user] %&gt;</b>
1520
+ <strong>&lt;% title = _context[:title] %&gt;</strong>
1521
+ <strong>&lt;% user = _context[:user] %&gt;</strong>
1393
1522
  &lt;html&gt;
1394
1523
  &lt;body&gt;hello&lt;/body&gt;
1395
1524
  &lt;/html&gt;
1396
- <b>&lt;%= "&lt;!--end--&gt;\n" %&gt;</b>
1525
+ <strong>&lt;%= "&lt;!--end--&gt;\n" %&gt;</strong>
1526
+ </pre>
1527
+ <br>
1528
+
1529
+
1530
+ <a name="detail-defun"></a>
1531
+ <h3 class="section2">Compile Template into a Function of Ruby or PHP</h3>
1532
+ <p>Using the command-line option '<code>-a defun</code>', you can compile templates into a function of Ruby or PHP.
1533
+ </p>
1534
+ <a name="defun1.html"></a>
1535
+ <div class="program_caption">
1536
+ defun1.html : presentation data</div>
1537
+ <pre class="program">Hello &lt;span id="user"&gt;user&lt;/span&gt; !
1538
+ &lt;ul id="mark:list"&gt;
1539
+ &lt;li id="mark:item"&gt;xxx&lt;/li&gt;
1540
+ &lt;/ul&gt;
1541
+ </pre>
1542
+ <a name="defun1.plogic"></a>
1543
+ <div class="program_caption">
1544
+ defun1.plogic : presentation logic</div>
1545
+ <pre class="program">#user {
1546
+ elem: @user;
1547
+ }
1548
+
1549
+ #list {
1550
+ logic: {
1551
+ _stag
1552
+ for item in @list
1553
+ _cont
1554
+ end
1555
+ _etag
1556
+ }
1557
+ }
1558
+
1559
+ #item {
1560
+ value: item;
1561
+ }
1562
+ </pre>
1563
+ <a name="defun1.expected"></a>
1564
+ <div class="terminal_caption">
1565
+ Compile</div>
1566
+ <pre class="terminal">$ kwartz -l eruby <strong>-a defun</strong> -p defun1.plogic defun1.html | tee defun1.rb
1567
+ <strong>module View</strong>
1568
+
1569
+ (@@proc_table ||= {})['defun1'] = proc do
1570
+ _erbout = ''; _erbout.concat "Hello "; _erbout.concat(( @user ).to_s); _erbout.concat " !\n"
1571
+ _erbout.concat "&lt;ul&gt;\n"
1572
+ for item in @list
1573
+ _erbout.concat " &lt;li&gt;"; _erbout.concat(( item ).to_s); _erbout.concat "&lt;/li&gt;\n"
1574
+ end
1575
+ _erbout.concat "&lt;/ul&gt;\n"
1576
+ _erbout
1577
+ end#proc
1578
+
1579
+ <strong>module_function</strong>
1580
+ <strong>def expand_defun1(context={})</strong>
1581
+ if context.is_a?(Hash)
1582
+ hash = context
1583
+ context = Object.new
1584
+ hash.each { |key, val| context.instance_variable_set("@#{key}", val) }
1585
+ end
1586
+ proc_obj = @@proc_table['defun1']
1587
+ context.instance_eval(&amp;proc_obj)
1588
+ <strong>end</strong>
1589
+
1590
+ <strong>end</strong>
1591
+ </pre>
1592
+ <p>The following command-line properties are available with '-a defun'.
1593
+ </p>
1594
+ <dl class="dl1">
1595
+ <dt class="dt1">
1596
+ --module=<em>name</em></dt>
1597
+ <dd class="dd1">
1598
+ Module name. If false or null then no module is used. Default is 'View'.
1599
+ </dd>
1600
+ <dt class="dt1">
1601
+ --verb=<em>name</em></dt>
1602
+ <dd class="dd1">
1603
+ Verb. Default is 'expand'.
1604
+ </dd>
1605
+ <dt class="dt1">
1606
+ --method=<em>name</em></dt>
1607
+ <dd class="dd1">
1608
+ Method name. Default is "#{verb}_#{basename}".
1609
+ </dd>
1610
+ </dl>
1611
+ <p>The following languages are available with '-a defun'.
1612
+ </p>
1613
+ <ul type="disc">
1614
+ <li>-l eruby
1615
+ </li>
1616
+ <li>-l ruby
1617
+ </li>
1618
+ <li>-l erubis
1619
+ </li>
1620
+ <li>-l pierubis
1621
+ </li>
1622
+ <li>-l php
1623
+ </li>
1624
+ </ul>
1625
+ <br>
1626
+
1627
+
1628
+ <br>
1629
+
1630
+
1631
+ <a name="rails"></a>
1632
+ <h2 class="section1">Ruby on Rails Support</h2>
1633
+ <p>This section shows how to use Kwartz with Ruby on Rails.
1634
+ See 'examples/rails1' and 'examples/rails2' for examples.
1635
+ </p>
1636
+ <a name="rails_template"></a>
1637
+ <h3 class="section2">Support of Ruby on Rails</h3>
1638
+ <p>If you want to use Kwartz with Ruby on Rails, add the following code in your 'app/controllers/application.rb' and restart web server.
1639
+ </p>
1640
+ <pre class="program">require 'kwartz/helper/rails'
1641
+ ActionView::Base.register_template_handler('html', Kwartz::Helper::RailsTemplate)
1642
+ #Kwartz::Helper::RailsTemplate.lang = 'rails' # or eruby/ruby/erubis/pierubis
1643
+ #Kwartz::Helper::RailsTemplate.pdata_suffix = '.html'
1644
+ #Kwartz::Helper::RailsTemplate.plogic_suffix = '.plogic'
1645
+ #Kwartz::Helper::RailsTemplate.default_properties = { :escape=&gt;false }
1646
+ #Kwartz::Helper::RailsTemplate.use_cache = true
1647
+ #Kwartz::Helper::RailsTemplate.debug = true
1648
+ </pre>
1649
+ <p>Layout files ('app/views/layouts/xxx.{html,plogic}') are also available.
1650
+ The following is an example to use layout files.
1651
+ </p>
1652
+ <div class="program_caption">
1653
+ app/views/member/list.html</div>
1654
+ <pre class="program">&lt;html&gt;
1655
+ &lt;body&gt;
1656
+ &lt;h1 <strong>id="page_title"</strong>&gt;&lt;/h1&gt;
1657
+ &lt;div <strong>id="page_content"</strong>&gt;
1658
+ &lt;ul id="mark:list"&gt;
1659
+ &lt;li id="mark:item"&gt;&lt;/li&gt;
1660
+ &lt;/ul&gt;
1661
+ &lt;/div&gt;
1662
+ &lt;/body&gt;
1663
+ &lt;/html&gt;
1664
+ </pre>
1665
+ <div class="program_caption">
1666
+ app/views/xxx/index.plogic</div>
1667
+ <pre class="program">#list {
1668
+ logic: {
1669
+ for item in @list
1670
+ _elem
1671
+ end
1672
+ }
1673
+ }
1674
+
1675
+ #item {
1676
+ value: item;
1677
+ }
1678
+ </pre>
1679
+ <div class="program_caption">
1680
+ app/views/layouts/xxx.html</div>
1681
+ <pre class="program">&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
1682
+ &lt;html&gt;
1683
+ &lt;head&gt;
1684
+ &lt;title id="mark:header_title"&gt;&lt;/title&gt;
1685
+ &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
1686
+ &lt;/head&gt;
1687
+ &lt;body&gt;
1688
+
1689
+ &lt;h1 class="title" <strong>id="replace_content_with_content:page_title"</strong>&gt;...page title...&lt;/h1&gt;
1690
+ &lt;div <strong>id="replace_element_with_content:page_content"</strong>&gt;
1691
+ ...page content...
1692
+ &lt;/div&gt;
1693
+
1694
+ &lt;p&gt;copyright&amp;copy; 2006 kuwata-lab.com all rights reserved.&lt;/p&gt;
1695
+
1696
+ &lt;/body&gt;
1697
+ &lt;/html&gt;
1698
+ </pre>
1699
+ <div class="program_caption">
1700
+ app/views/layouts/xxx.plogic</div>
1701
+ <pre class="program">#header_title {
1702
+ cont: 'Member: ' + controller.action_name;
1703
+ }
1704
+ </pre>
1705
+ <p>See the 'examples/rails2' directory for example of using Kwartz with Ruby on Rails.
1706
+ </p>
1707
+ <br>
1708
+
1709
+
1710
+ <a name="rails_start_link_tag"></a>
1711
+ <h3 class="section2"><code>link_to()</code> method in Ruby on Rails</h3>
1712
+ <p><code>link_to()</code> method in Ruby on Rails is a little incompatible with Kwartz
1713
+ because you must specify link label in both presentation data and presentation logic.
1714
+ It's not DRY.
1715
+ </p>
1716
+ <div class="program_caption">
1717
+ presentation data</div>
1718
+ <pre class="program">&lt;a href="#" id="mark:link_to_new"&gt;<strong>Create new recipe</strong>&lt;/a&gt;
1719
+ </pre>
1720
+ <div class="program_caption">
1721
+ presentation logic</div>
1722
+ <pre class="program">#link_to_new {
1723
+ elem: link_to <strong>'Create new recipe'</strong>, :action=&gt;'new';
1724
+ }
1725
+ </pre>
1726
+ <p>It is recommended to use start_link_tag() and start_remote_link_tag() instead of link_to() and link_to_remote() because the formers print only start tag of anchor.
1727
+ </p>
1728
+ <div class="program_caption">
1729
+ presentation data</div>
1730
+ <pre class="program">&lt;a href="#" id="mark:link_to_new"&gt;Create new recipe&lt;/a&gt;
1731
+ </pre>
1732
+ <div class="program_caption">
1733
+ presentation logic</div>
1734
+ <pre class="program">#link_to_new {
1735
+ stag: <strong>start_link_tag</strong> :action=&gt;'new', :controller=&gt;'recipes';
1736
+ }
1737
+ </pre>
1738
+ <div class="program_caption">
1739
+ expected result</div>
1740
+ <pre class="program">&lt;a href="/recipes/new"&gt;Create new recipe&lt;/a&gt;
1741
+ </pre>
1742
+ <p>To use start_link_tag() and start_remote_link_tag(), include Kwartz::Helper::ActionViewHelper to ApplicationHelper module in 'app/helpers/application_helper.rb'.
1743
+ </p>
1744
+ <div class="program_caption">
1745
+ app/helpers/application_helper.rb</div>
1746
+ <pre class="program"><strong>require 'kwartz/helper/rails'</strong>
1747
+ module ApplicationHelper
1748
+ <strong>include Kwartz::Helper::ActionViewHelper</strong>
1749
+ end
1750
+ </pre>
1751
+ <p>The following is the definition of start_link_tag() and start_remote_link_tag().
1752
+ They are defined in Kwartz::Helper::ActionViewHelper module which is defined in
1753
+ 'kwartz/helper/rails.rb'.
1754
+ </p>
1755
+ <div class="program_caption">
1756
+ definition of start_link_tag() and start_remote_link_tag()</div>
1757
+ <pre class="program">module Kwartz::Helper::ActionViewHelper
1758
+
1759
+ def start_link_tag(options = {}, html_options = nil, *parameters_for_method_reference)
1760
+ s = link_to('', options, html_options, *parameters_for_method_reference)
1761
+ s.sub!(/&lt;\/a&gt;\z/, '')
1762
+ s
1763
+ end
1764
+ alias anchor start_link_tag
1765
+
1766
+ def start_remote_link_tag(options = {}, html_options = {})
1767
+ s = link_to_remote(options, html_options)
1768
+ s.sub!(/&lt;\/a&gt;\z/, '')
1769
+ s
1770
+ end
1771
+ alias anchor_remote start_remote_link_tag
1772
+
1773
+ end
1774
+ </pre>
1775
+ <br>
1776
+
1777
+
1778
+ <a name="rails-layout"></a>
1779
+ <h3 class="section2">Layout Option in Controller</h3>
1780
+ <ul type="disc">
1781
+ <li><code>layout()</code> is available.
1782
+ <pre class="program">class MemberController &lt; ApplicationController
1783
+ <strong>layout 'members2', :except=&gt;['show', 'edit']</strong>
1784
+ ...
1785
+ end
1786
+ </pre>
1787
+ </li>
1788
+ </ul>
1789
+ <ul type="disc">
1790
+ <li><code>render()</code> with <code>:layout</code> parameter is available.
1791
+ <pre class="program">class MemberController &lt; ApplicationController
1792
+ def list
1793
+ @member_pages, @members = paginate :members, :per_page =&gt; 10
1794
+ <strong>render :layout =&gt; 'members2'</strong>
1795
+ end
1796
+ ...
1797
+ end
1798
+ </pre>
1799
+ </li>
1800
+ </ul>
1801
+ <br>
1802
+
1803
+
1804
+ <a name="rails-scaffold"></a>
1805
+ <h3 class="section2">Scaffold Kwartz Template</h3>
1806
+ <p>There is no 'generate scaffold' script for Kwartz template.
1807
+ Instead, use <a href="http://kwatable.rubyforge.net">Kwatable</a>.
1808
+ </p>
1809
+ <p><a href="http://kwatable.rubyforge.net">Kwatable</a> is a script to generate severail files (SQL, DTO, Kwartz template, and so on) from table definition file.
1810
+ It's more sophisticated than Rails' scaffold generating script.
1811
+ </p>
1812
+ <br>
1813
+
1814
+
1815
+ <a name="rails-helper-methods"></a>
1816
+ <h3 class="section2">Rails Helper Methods</h3>
1817
+ <p>(Notice: this is experimental feature. The spec may be changed in the future.)
1818
+ </p>
1819
+ <p>It is able to embed Rails' helper method in kw:d attribute.
1820
+ </p>
1821
+ <pre class="program">## text_field, password_field
1822
+ &lt;input type="text" size="10" maxsize="20" <strong>kw:d="text_field 'user', 'name'"</strong>&gt;
1823
+ =&gt; &lt;%= text_field 'user', 'name', :size=&gt;10, :maxsize=&gt;20 %&gt;
1824
+ &lt;input type="text" name="user[name]" <strong>kw:d="text_field :size=&gt;10"</strong>&gt;
1825
+ =&gt; &lt;%= text_field "user", "name", :size=&gt;10 %&gt;
1826
+ &lt;input type="text" id="user_name" size="10" <strong>kw:d="text_field"</strong>&gt;
1827
+ =&gt; &lt;%= text_field "user", "name", :size=&gt;10 %&gt;
1828
+
1829
+ ## link_to, link_to_remote
1830
+ &lt;a href="#" <strong>kw:d="link_to :action=&gt;'list'"</strong>&gt;Show list&lt;/a&gt;
1831
+ =&gt; &lt;%= link_to 'Show list', :action=&gt;'list' %&gt;
1832
+
1833
+ ## start_link_tag, start_remote_link_tag
1834
+ &lt;a href="#" <strong>kw:d="start_link_tag :action=&gt;'list'"</strong>&gt;Show list&lt;/a&gt;
1835
+ =&gt; &lt;%= start_link_tag 'action'=&gt;'list' %&gt;Show list&lt;/a&gt;
1836
+
1837
+ ## mail_to
1838
+ &lt;a href="mail:www@example.com" <strong>kw:d="mail_to"</strong>&gt;admin&lt;/a&gt;
1839
+ =&gt; &lt;%= mail_to "www@example.com", "admin" %&gt;
1840
+
1841
+ ## form_tag
1842
+ &lt;form action="show" <strong>kw:d="form_tag :id=&gt;2"</strong>&gt; ... &lt;/form&gt;
1843
+ =&gt; &lt;%= form_tag :action=&gt;"show", :id=&gt;2 %&gt; ... &lt;/form&gt;
1844
+
1845
+ ## submit_tag
1846
+ &lt;input type="submit" value="OK" <strong>kw:d="submit_tag"</strong>&gt;
1847
+ =&gt; &lt;%= submit_tag "OK" %&gt;
1848
+
1849
+ ## text_area
1850
+ &lt;textarea cols="30" rows="3" id="user_desc" <strong>kw:d="text_area"</strong>&gt;&lt;/textarea&gt;
1851
+ =&gt; &lt;%= text_area "user", "desc", :cols=&gt;30, :rows=&gt;3 %&gt;
1852
+ &lt;textarea cols="30" rows="3" name="user[desc]" <strong>kw:d="text_area"</strong>&gt;&lt;/textarea&gt;
1853
+ =&gt; &lt;%= text_area "user", "desc", :cols=&gt;30, :rows=&gt;3 %&gt;
1854
+
1855
+ ## hidden_field
1856
+ &lt;input type="hidden" id="user_id" <strong>kw:d="hidden_field"</strong>&gt;
1857
+ =&gt; &lt;%= hidden_field "user", "id" %&gt;
1858
+ &lt;input type="hidden" name="user[id]" <strong>kw:d="hidden_field"</strong>&gt;
1859
+ =&gt; &lt;%= hidden_field "user", "id" %&gt;
1860
+
1861
+ ## check_box
1862
+ &lt;input type="checkbox" id="user_chk1" <strong>kw:d="check_box"</strong>&gt;
1863
+ =&gt; &lt;%= check_box "user", "chk1" %&gt;
1864
+ &lt;input type="checkbox" name="user[chk2]" <strong>kw:d="check_box"</strong>&gt;
1865
+ =&gt; &lt;%= check_box "user", "chk2" %&gt;
1866
+
1867
+ ## radio_button
1868
+ &lt;input type="radio" id="user_radio" value="val1" <strong>kw:d="radio_button"</strong>&gt;
1869
+ =&gt; &lt;%= radio_button "user", "radio", "val1" %&gt;
1870
+ &lt;input type="radio" name="user[radio]" value="val2" <strong>kw:d="radio_button"</strong>&gt;
1871
+ =&gt; &lt;%= radio_button "user", "radio", "val2" %&gt;
1872
+
1873
+ ## select, collection_select, country_select, time_zone_select, date_select, datetime_select
1874
+ &lt;select name="user[birth]" <strong>kw:d="date_select :start_year=&gt;1970"</strong>&gt;
1875
+ &lt;option value="2000"&gt;2000&lt;/option&gt;
1876
+ &lt;/select&gt;
1877
+ =&gt; &lt;% date_select "user", "birth", :start_year=&gt;1970 %&gt;
1878
+
1879
+ ## image_tag, link_image_to, link_to_image
1880
+ &lt;img src="foo.gif" alt="text" width="20" heigth="10" <strong>kw:d="image_tag :size=&gt;'30x40'"</strong>&gt;
1881
+ =&gt; &lt;%= image_tag "foo.gif", :alt=&gt;"text", :size=&gt;'30x40' %&gt;
1397
1882
  </pre>
1398
1883
  <br>
1399
1884
 
@@ -1403,7 +1888,7 @@ compile</div>
1403
1888
 
1404
1889
  <a name="topics"></a>
1405
1890
  <h2 class="section1">Other Topics</h2>
1406
- <a name="restriction1"></a>
1891
+ <a name="topics-restriction1"></a>
1407
1892
  <h3 class="section2">Restrictions around presentation logic</h3>
1408
1893
  <p>There are several restrictions in presentation logic file.
1409
1894
  </p>
@@ -1477,7 +1962,7 @@ compile</div>
1477
1962
  <br>
1478
1963
 
1479
1964
 
1480
- <a name="restriction2"></a>
1965
+ <a name="topics-restriction2"></a>
1481
1966
  <h3 class="section2">Restrictions around presentation data</h3>
1482
1967
  <p>Kwartz parses presentation data file by regular expression pattern matching.
1483
1968
  It means that Kwartz doesn't use HTML parser nor XML parser for parsing presentation data.
@@ -1506,14 +1991,14 @@ This approach enables Kwartz to handle any type of text file, and also brings th
1506
1991
  <ul type="disc">
1507
1992
  <li>Attribute values should be surrounded with '<code>"</code>'.
1508
1993
  <pre class="program">&lt;!-- Kwartz fails parsing because attribute value is not surrounded with '"'. --&gt;
1509
- &lt;h1 id="value:title" class=title&gt;title&lt;/h1&gt;
1994
+ &lt;h1 id='id:title' class=title&gt;title&lt;/h1&gt;
1510
1995
  </pre>
1511
1996
  </li>
1512
1997
  </ul>
1513
1998
  <br>
1514
1999
 
1515
2000
 
1516
- <a name="makefile"></a>
2001
+ <a name="topics-makefile"></a>
1517
2002
  <h3 class="section2">Makefile and Rakefile</h3>
1518
2003
  <p>The followings are examples of Makefile, Rakefile, Rantfile, and Rookbook.
1519
2004
  </p>
@@ -1567,94 +2052,112 @@ file "file3.rhtml" =&gt; ["file3.html", "file3.plogic", layout] do |t|
1567
2052
  end
1568
2053
  </pre>
1569
2054
  <div class="program_caption">
1570
- example of Rookbook for <a href="http://www.rubyforge.org/projects/rook">Rook</a></div>
2055
+ example of Rookbook.yaml for <a href="http://www.rubyforge.org/projects/rook">Rook</a></div>
1571
2056
  <pre class="program">properties:
1572
2057
  - layout : layout.html
1573
2058
 
1574
- variables:
1575
- - all : [ file1.rhtml, 'file2.rhtml', file3.rhtml ]
2059
+ parameters:
2060
+ - all : [ file1.rhtml, file2.rhtml, file3.rhtml ]
1576
2061
  - rook_product: $(all)
1577
2062
 
1578
2063
  recipes:
1579
2064
 
1580
2065
  - product: *.rhtml
1581
2066
  ingreds: [ $(1).html, $(1).plogic ]
1582
- method: |
2067
+ method*: |
1583
2068
  pdata, plogic = @ingreds
1584
2069
  sys "kwartz -p #{plogic} #{pdata} &gt; #{@product}"
1585
2070
 
1586
2071
  - product: file3.rhtml
1587
2072
  ingres: [ file3.html, file3.plogic, $(layout) ]
1588
- method: |
2073
+ method*: |
1589
2074
  pdata, plogic, layout = @ingreds
1590
2075
  sys "kwartz- p #{plogic} -L $(layout) #{pdata} &gt; #{@product}"
1591
2076
  </pre>
1592
2077
  <br>
1593
2078
 
1594
2079
 
1595
- <a name="kwartz-lib"></a>
2080
+ <a name="topics-kwartz-lib"></a>
1596
2081
  <h3 class="section2">Use Kwartz as Library</h3>
1597
2082
  <p>If you want to use Kwartz library in your Ruby script, use Kwartz::Main class.
1598
2083
  </p>
1599
2084
  <div class="program_caption">
1600
2085
  usage of Kwartz::Main class</div>
1601
- <pre class="program"><b>require 'kwartz'</b>
1602
- <b>require 'kwartz/main'</b>
2086
+ <pre class="program"><strong>require 'kwartz'</strong>
2087
+ <strong>require 'kwartz/main'</strong>
1603
2088
 
1604
2089
  argv = %w[-p hello.plogic -L layout.html hello.html]
1605
- <b>main = Kwartz::Main.new(argv)</b>
1606
- <b>output = main.execute()</b>
2090
+ <strong>main = Kwartz::Main.new(argv)</strong>
2091
+ <strong>output = main.execute()</strong>
1607
2092
  File.open('hello.rhtml', 'w') { |f| f.write(output) }
1608
2093
  </pre>
1609
2094
  <br>
1610
2095
 
1611
2096
 
1612
- <a name="start_link_to"></a>
1613
- <h3 class="section2"><code>link_to()</code> method in Ruby on Rails</h3>
1614
- <p><code>link_to()</code> method in Ruby on Rails is a little incompatible with Kwartz
1615
- because you must specify link label in both presentation data and presentation logic.
1616
- It's not DRY.
2097
+ <a name="topics-erubis"></a>
2098
+ <h3 class="section2">Use Kwartz with Non-Supported Language</h3>
2099
+ <p>Using <a href="http://www.kuwata-lab.com/erubis">Erubis</a>, it is able to use Kwartz with Java, JavaScript, Scheme, and so on.
2100
+ Erubis is an implementation of eRuby which supports not only Ruby but also other languages.
2101
+ </p>
2102
+ <p>The followings are examples of using JavaScript with Kwartz and Erubis.
1617
2103
  </p>
2104
+ <a name="js-example.html"></a>
1618
2105
  <div class="program_caption">
1619
- presentation data</div>
1620
- <pre class="program">&lt;a href="#" id="mark:link_to_new"&gt;<b>Create new recipe</b>&lt;/a&gt;
2106
+ presentation data (js-example.html)</div>
2107
+ <pre class="program">&lt;table&gt;
2108
+ &lt;tr class="odd" <strong>id="mark:list"</strong>&gt;
2109
+ &lt;td&gt;<strong>@!{item}@</strong>&lt;/td&gt;
2110
+ &lt;/tr&gt;
2111
+ &lt;tr class="even" <strong>id="dummy:d1"</strong>&gt;
2112
+ &lt;td&gt;foo&lt;/td&gt;
2113
+ &lt;/tr&gt;
2114
+ &lt;/table&gt;
1621
2115
  </pre>
2116
+ <a name="js-example.plogic"></a>
1622
2117
  <div class="program_caption">
1623
- presentation logic</div>
1624
- <pre class="program">#link_to_new {
1625
- elem: link_to <b>'Create new recipe'</b>, :action=&gt;'new';
2118
+ presentation logic (js-example.plogic)</div>
2119
+ <pre class="program">#list {
2120
+ attrs: 'class' klass;
2121
+ logic: {
2122
+ for (var i=0, len=list.length; i &lt; len; i++) {
2123
+ klass = i % 1 == 0 ? 'even' : 'odd';
2124
+ item = list[i];
2125
+ _elem;
2126
+ }
2127
+ }
1626
2128
  }
1627
2129
  </pre>
1628
- <p>It is recommended to include the following helper method
1629
- in your 'app/helpers/application_helper.rb'.
1630
- </p>
1631
- <pre class="program">module ApplicationHelper
1632
-
1633
- def start_link_to(options = {}, html_options = nil, *parameters_for_method_reference)
1634
- s = link_to('', options, html_options, *parameters_for_method_reference)
1635
- s.sub!(/&lt;\/a&gt;\z/, '')
1636
- end
1637
- alias anchor start_link_to
1638
-
1639
- def start_link_to_remote(options = {}, html_options = {})
1640
- s = link_to_remote(options, html_options)
1641
- s.sub!(/&lt;\/a&gt;\z/, '')
1642
- end
1643
- alias anchor_remote start_link_to_remote
1644
-
1645
- end
2130
+ <div class="terminal_caption">
2131
+ compile</div>
2132
+ <pre class="terminal">$ kwartz <strong>-l erubis</strong> -p js-example.plogic js-example.html &gt; js-example.jshtml
1646
2133
  </pre>
1647
- <p>The above methods prints only start tag. You don't need to write label twice.
1648
- </p>
2134
+ <a name="js-example.jshtml"></a>
1649
2135
  <div class="program_caption">
1650
- presentation data</div>
1651
- <pre class="program">&lt;a href="#" id="mark:link_to_new"&gt;Create new recipe&lt;/a&gt;
2136
+ output script (js-example.jshtml)</div>
2137
+ <pre class="program">&lt;table&gt;
2138
+ <strong>&lt;% for (var i=0, len=list.length; i &lt; len; i++) { %&gt;</strong>
2139
+ <strong>&lt;% klass = i % 1 == 0 ? 'even' : 'odd'; %&gt;</strong>
2140
+ <strong>&lt;% item = list[i]; %&gt;</strong>
2141
+ &lt;tr class="<strong>&lt;%= klass %&gt;</strong>"&gt;
2142
+ &lt;td&gt;<strong>&lt;%= item %&gt;</strong>&lt;/td&gt;
2143
+ &lt;/tr&gt;
2144
+ <strong>&lt;% } %&gt;</strong>
2145
+ &lt;/table&gt;
1652
2146
  </pre>
1653
- <div class="program_caption">
1654
- presentation logic</div>
1655
- <pre class="program">#link_to_new {
1656
- stag: <b>start_link_to</b> :action=&gt;'new';
1657
- }
2147
+ <a name="js-example.expected"></a>
2148
+ <div class="terminal_caption">
2149
+ convert into JavaScript code with erubis</div>
2150
+ <pre class="terminal">$ erubis -l javascript -x js-example.jshtml
2151
+ var _buf = []; _buf.push("&lt;table&gt;\n");
2152
+ <strong>for (var i=0, len=list.length; i &lt; len; i++) {</strong>
2153
+ <strong>klass = i % 1 == 0 ? 'even' : 'odd';</strong>
2154
+ <strong>item = list[i];</strong>
2155
+ _buf.push(" &lt;tr class=\""); _buf.push(<strong>klass</strong>); _buf.push("\"&gt;\n\
2156
+ &lt;td&gt;"); _buf.push(<strong>item</strong>); _buf.push("&lt;/td&gt;\n\
2157
+ &lt;/tr&gt;\n");
2158
+ <strong>}</strong>
2159
+ _buf.push("&lt;/table&gt;\n");
2160
+ document.write(_buf.join(""));
1658
2161
  </pre>
1659
2162
  <br>
1660
2163