kwartz 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -112,13 +112,13 @@ example of presentation logic in css style:
112
112
  <h3 class="section-bar">Methods</h3>
113
113
 
114
114
  <div class="name-list">
115
- <a href="#M000042">has_colon?</a>&nbsp;&nbsp;
116
- <a href="#M000040">keywords</a>&nbsp;&nbsp;
117
- <a href="#M000038">parse</a>&nbsp;&nbsp;
118
- <a href="#M000041">parse_document_ruleset</a>&nbsp;&nbsp;
119
- <a href="#M000043">parse_element_ruleset</a>&nbsp;&nbsp;
120
- <a href="#M000044">parse_import_command</a>&nbsp;&nbsp;
121
- <a href="#M000039">scan_hook</a>&nbsp;&nbsp;
115
+ <a href="#M000078">has_colon?</a>&nbsp;&nbsp;
116
+ <a href="#M000076">keywords</a>&nbsp;&nbsp;
117
+ <a href="#M000074">parse</a>&nbsp;&nbsp;
118
+ <a href="#M000077">parse_document_ruleset</a>&nbsp;&nbsp;
119
+ <a href="#M000079">parse_element_ruleset</a>&nbsp;&nbsp;
120
+ <a href="#M000080">parse_import_command</a>&nbsp;&nbsp;
121
+ <a href="#M000075">scan_hook</a>&nbsp;&nbsp;
122
122
  </div>
123
123
  </div>
124
124
 
@@ -153,21 +153,21 @@ example of presentation logic in css style:
153
153
  <div id="methods">
154
154
  <h3 class="section-bar">Public Instance methods</h3>
155
155
 
156
- <div id="method-M000038" class="method-detail">
157
- <a name="M000038"></a>
156
+ <div id="method-M000074" class="method-detail">
157
+ <a name="M000074"></a>
158
158
 
159
159
  <div class="method-heading">
160
- <a href="#M000038" class="method-signature">
160
+ <a href="#M000074" class="method-signature">
161
161
  <span class="method-name">parse</span><span class="method-args">(input, filename='')</span>
162
162
  </a>
163
163
  </div>
164
164
 
165
165
  <div class="method-description">
166
166
  <p><a class="source-toggle" href="#"
167
- onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
168
- <div class="method-source-code" id="M000038-source">
167
+ onclick="toggleCode('M000074-source');return false;">[Source]</a></p>
168
+ <div class="method-source-code" id="M000074-source">
169
169
  <pre>
170
- <span class="ruby-comment cmt"># File kwartz/parser.rb, line 595</span>
170
+ <span class="ruby-comment cmt"># File kwartz/parser.rb, line 603</span>
171
171
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse</span>(<span class="ruby-identifier">input</span>, <span class="ruby-identifier">filename</span>=<span class="ruby-value str">''</span>)
172
172
  <span class="ruby-identifier">reset</span>(<span class="ruby-identifier">input</span>, <span class="ruby-identifier">filename</span>)
173
173
  <span class="ruby-identifier">scan</span>()
@@ -187,11 +187,10 @@ example of presentation logic in css style:
187
187
  <span class="ruby-identifier">scan_ident</span>()
188
188
  <span class="ruby-identifier">name</span> = <span class="ruby-ivar">@value</span>
189
189
  <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'DOCUMENT'</span>
190
- <span class="ruby-identifier">ruleset</span> = <span class="ruby-identifier">parse_document_ruleset</span>()
190
+ <span class="ruby-identifier">rulesets</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">parse_document_ruleset</span>()
191
191
  <span class="ruby-keyword kw">else</span>
192
- <span class="ruby-identifier">ruleset</span> = <span class="ruby-identifier">parse_element_ruleset</span>()
192
+ <span class="ruby-identifier">rulesets</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">parse_element_ruleset</span>()
193
193
  <span class="ruby-keyword kw">end</span>
194
- <span class="ruby-identifier">rulesets</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">ruleset</span>
195
194
  <span class="ruby-keyword kw">end</span>
196
195
  <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@token</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
197
196
  <span class="ruby-identifier">raise</span> <span class="ruby-identifier">parse_error</span>(<span class="ruby-node">&quot;'#{@value}': '#name' is expected.&quot;</span>)
@@ -205,21 +204,21 @@ example of presentation logic in css style:
205
204
 
206
205
  <h3 class="section-bar">Protected Instance methods</h3>
207
206
 
208
- <div id="method-M000042" class="method-detail">
209
- <a name="M000042"></a>
207
+ <div id="method-M000078" class="method-detail">
208
+ <a name="M000078"></a>
210
209
 
211
210
  <div class="method-heading">
212
- <a href="#M000042" class="method-signature">
211
+ <a href="#M000078" class="method-signature">
213
212
  <span class="method-name">has_colon?</span><span class="method-args">()</span>
214
213
  </a>
215
214
  </div>
216
215
 
217
216
  <div class="method-description">
218
217
  <p><a class="source-toggle" href="#"
219
- onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
220
- <div class="method-source-code" id="M000042-source">
218
+ onclick="toggleCode('M000078-source');return false;">[Source]</a></p>
219
+ <div class="method-source-code" id="M000078-source">
221
220
  <pre>
222
- <span class="ruby-comment cmt"># File kwartz/parser.rb, line 722</span>
221
+ <span class="ruby-comment cmt"># File kwartz/parser.rb, line 730</span>
223
222
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_colon?</span>
224
223
  <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@ch</span> <span class="ruby-operator">==</span> <span class="ruby-value">?:</span>
225
224
  <span class="ruby-identifier">raise</span> <span class="ruby-identifier">parse_error</span>(<span class="ruby-node">&quot;'#{@value}': ':' is required.&quot;</span>)
@@ -231,21 +230,21 @@ example of presentation logic in css style:
231
230
  </div>
232
231
  </div>
233
232
 
234
- <div id="method-M000040" class="method-detail">
235
- <a name="M000040"></a>
233
+ <div id="method-M000076" class="method-detail">
234
+ <a name="M000076"></a>
236
235
 
237
236
  <div class="method-heading">
238
- <a href="#M000040" class="method-signature">
237
+ <a href="#M000076" class="method-signature">
239
238
  <span class="method-name">keywords</span><span class="method-args">(keyword)</span>
240
239
  </a>
241
240
  </div>
242
241
 
243
242
  <div class="method-description">
244
243
  <p><a class="source-toggle" href="#"
245
- onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
246
- <div class="method-source-code" id="M000040-source">
244
+ onclick="toggleCode('M000076-source');return false;">[Source]</a></p>
245
+ <div class="method-source-code" id="M000076-source">
247
246
  <pre>
248
- <span class="ruby-comment cmt"># File kwartz/parser.rb, line 683</span>
247
+ <span class="ruby-comment cmt"># File kwartz/parser.rb, line 691</span>
249
248
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">keywords</span>(<span class="ruby-identifier">keyword</span>)
250
249
  <span class="ruby-keyword kw">return</span> <span class="ruby-constant">CSSSTYLE_KEYWORDS</span>[<span class="ruby-identifier">keyword</span>]
251
250
  <span class="ruby-keyword kw">end</span>
@@ -254,21 +253,21 @@ example of presentation logic in css style:
254
253
  </div>
255
254
  </div>
256
255
 
257
- <div id="method-M000041" class="method-detail">
258
- <a name="M000041"></a>
256
+ <div id="method-M000077" class="method-detail">
257
+ <a name="M000077"></a>
259
258
 
260
259
  <div class="method-heading">
261
- <a href="#M000041" class="method-signature">
260
+ <a href="#M000077" class="method-signature">
262
261
  <span class="method-name">parse_document_ruleset</span><span class="method-args">()</span>
263
262
  </a>
264
263
  </div>
265
264
 
266
265
  <div class="method-description">
267
266
  <p><a class="source-toggle" href="#"
268
- onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
269
- <div class="method-source-code" id="M000041-source">
267
+ onclick="toggleCode('M000077-source');return false;">[Source]</a></p>
268
+ <div class="method-source-code" id="M000077-source">
270
269
  <pre>
271
- <span class="ruby-comment cmt"># File kwartz/parser.rb, line 689</span>
270
+ <span class="ruby-comment cmt"># File kwartz/parser.rb, line 697</span>
272
271
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_document_ruleset</span>
273
272
  <span class="ruby-identifier">assert</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@value</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'DOCUMENT'</span>
274
273
  <span class="ruby-identifier">start_linenum</span> = <span class="ruby-ivar">@linenum</span>
@@ -284,8 +283,8 @@ example of presentation logic in css style:
284
283
  <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:global</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_global</span> <span class="ruby-identifier">_parse_words</span>()
285
284
  <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:local</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_local</span> <span class="ruby-identifier">_parse_words</span>()
286
285
  <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:fixture</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_fixture</span> <span class="ruby-identifier">_parse_block</span>()
287
- <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:begin</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_begin</span> <span class="ruby-identifier">_parse_block</span>()
288
- <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:end</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_end</span> <span class="ruby-identifier">_parse_block</span>()
286
+ <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:begin</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_begin</span> <span class="ruby-identifier">_parse_block</span>()
287
+ <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:end</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_end</span> <span class="ruby-identifier">_parse_block</span>()
289
288
  <span class="ruby-comment cmt">#when :before ; has_colon?(); ruleset.set_before _parse_block()</span>
290
289
  <span class="ruby-comment cmt">#when :after ; has_colon?(); ruleset.set_after _parse_block()</span>
291
290
  <span class="ruby-keyword kw">else</span>
@@ -305,29 +304,41 @@ example of presentation logic in css style:
305
304
  </div>
306
305
  </div>
307
306
 
308
- <div id="method-M000043" class="method-detail">
309
- <a name="M000043"></a>
307
+ <div id="method-M000079" class="method-detail">
308
+ <a name="M000079"></a>
310
309
 
311
310
  <div class="method-heading">
312
- <a href="#M000043" class="method-signature">
311
+ <a href="#M000079" class="method-signature">
313
312
  <span class="method-name">parse_element_ruleset</span><span class="method-args">()</span>
314
313
  </a>
315
314
  </div>
316
315
 
317
316
  <div class="method-description">
318
317
  <p><a class="source-toggle" href="#"
319
- onclick="toggleCode('M000043-source');return false;">[Source]</a></p>
320
- <div class="method-source-code" id="M000043-source">
318
+ onclick="toggleCode('M000079-source');return false;">[Source]</a></p>
319
+ <div class="method-source-code" id="M000079-source">
321
320
  <pre>
322
- <span class="ruby-comment cmt"># File kwartz/parser.rb, line 730</span>
321
+ <span class="ruby-comment cmt"># File kwartz/parser.rb, line 738</span>
323
322
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_element_ruleset</span>
324
323
  <span class="ruby-identifier">assert</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@token</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:ident</span>
325
324
  <span class="ruby-identifier">start_linenum</span> = <span class="ruby-ivar">@linenum</span>
326
325
  <span class="ruby-identifier">name</span> = <span class="ruby-ivar">@value</span>
326
+ <span class="ruby-comment cmt">#names = [name]</span>
327
+ <span class="ruby-identifier">names</span> = []
327
328
  <span class="ruby-identifier">scan</span>()
329
+ <span class="ruby-keyword kw">while</span> <span class="ruby-ivar">@token</span> <span class="ruby-operator">==</span> <span class="ruby-value str">','</span><span class="ruby-value str">','</span>
330
+ <span class="ruby-identifier">scan</span>()
331
+ <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@token</span> <span class="ruby-operator">==</span> <span class="ruby-value">?#</span>
332
+ <span class="ruby-identifier">raise</span> <span class="ruby-identifier">parse_error</span>(<span class="ruby-node">&quot;'#{@value}': '#name' is expected.&quot;</span>)
333
+ <span class="ruby-keyword kw">end</span>
334
+ <span class="ruby-identifier">scan_ident</span>()
335
+ <span class="ruby-identifier">names</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@value</span>
336
+ <span class="ruby-identifier">scan</span>()
337
+ <span class="ruby-keyword kw">end</span>
328
338
  <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@token</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'{'</span><span class="ruby-value str">'{'</span>
329
339
  <span class="ruby-identifier">raise</span> <span class="ruby-identifier">parse_error</span>(<span class="ruby-node">&quot;'#{@value}': '{' is expected.&quot;</span>)
330
340
  <span class="ruby-keyword kw">end</span>
341
+
331
342
  <span class="ruby-identifier">ruleset</span> = <span class="ruby-constant">ElementRuleset</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">name</span>)
332
343
  <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
333
344
  <span class="ruby-identifier">scan</span>()
@@ -343,45 +354,53 @@ example of presentation logic in css style:
343
354
  <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:attrs</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_attrs</span> <span class="ruby-identifier">_parse_pairs</span>(), <span class="ruby-identifier">flag_escape</span>
344
355
  <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:append</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_append</span> <span class="ruby-identifier">_parse_exprs</span>(), <span class="ruby-identifier">flag_escape</span>
345
356
  <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:remove</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_remove</span> <span class="ruby-identifier">_parse_strs</span>()
346
- <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:tagname</span>; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_tagname</span> <span class="ruby-identifier">_parse_str</span>()
357
+ <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:tagname</span>; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_tagname</span> <span class="ruby-identifier">_parse_str</span>()
347
358
  <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:logic</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_logic</span> <span class="ruby-identifier">_parse_block</span>()
348
359
  <span class="ruby-keyword kw">else</span>
349
360
  <span class="ruby-identifier">raise</span> <span class="ruby-identifier">parse_error</span>(<span class="ruby-node">&quot;'#{@value}': unexpected token.&quot;</span>)
350
361
  <span class="ruby-keyword kw">end</span>
351
362
  <span class="ruby-keyword kw">end</span>
363
+ <span class="ruby-comment cmt">## build rulesets</span>
364
+ <span class="ruby-identifier">rulesets</span> = [<span class="ruby-identifier">ruleset</span>]
365
+ <span class="ruby-identifier">names</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-identifier">rulesets</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">duplicate</span>(<span class="ruby-identifier">name</span>) <span class="ruby-keyword kw">end</span>
366
+
352
367
  <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@token</span>
353
368
  <span class="ruby-identifier">raise</span> <span class="ruby-identifier">parse_error</span>(<span class="ruby-node">&quot;'##{name}': is not closed by '}'.&quot;</span>, <span class="ruby-identifier">start_linenum</span>)
354
369
  <span class="ruby-keyword kw">end</span>
355
370
  <span class="ruby-identifier">assert</span> <span class="ruby-node">&quot;@token=#{@token.inspect}&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@token</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'}'</span><span class="ruby-value str">'}'</span>
356
371
  <span class="ruby-identifier">scan</span>()
357
- <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">ruleset</span>
372
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">rulesets</span>
358
373
  <span class="ruby-keyword kw">end</span>
359
374
  </pre>
360
375
  </div>
361
376
  </div>
362
377
  </div>
363
378
 
364
- <div id="method-M000044" class="method-detail">
365
- <a name="M000044"></a>
379
+ <div id="method-M000080" class="method-detail">
380
+ <a name="M000080"></a>
366
381
 
367
382
  <div class="method-heading">
368
- <a href="#M000044" class="method-signature">
383
+ <a href="#M000080" class="method-signature">
369
384
  <span class="method-name">parse_import_command</span><span class="method-args">()</span>
370
385
  </a>
371
386
  </div>
372
387
 
373
388
  <div class="method-description">
374
389
  <p><a class="source-toggle" href="#"
375
- onclick="toggleCode('M000044-source');return false;">[Source]</a></p>
376
- <div class="method-source-code" id="M000044-source">
390
+ onclick="toggleCode('M000080-source');return false;">[Source]</a></p>
391
+ <div class="method-source-code" id="M000080-source">
377
392
  <pre>
378
- <span class="ruby-comment cmt"># File kwartz/parser.rb, line 768</span>
393
+ <span class="ruby-comment cmt"># File kwartz/parser.rb, line 792</span>
379
394
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_import_command</span>
380
395
  <span class="ruby-identifier">c</span> = <span class="ruby-ivar">@ch</span>
381
396
  <span class="ruby-identifier">c</span> = <span class="ruby-identifier">getch</span>() <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">is_whitespace</span>(<span class="ruby-identifier">c</span>)
382
397
  <span class="ruby-identifier">t</span> = <span class="ruby-identifier">scan_string</span>()
383
398
  <span class="ruby-identifier">t</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:string</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-identifier">parse_error</span>(<span class="ruby-value str">&quot;@import: requires filename.&quot;</span>)
384
399
  <span class="ruby-identifier">filename</span> = <span class="ruby-ivar">@value</span>
400
+ <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@filename</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@filename</span>.<span class="ruby-identifier">empty?</span>
401
+ <span class="ruby-identifier">dir</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-ivar">@filename</span>)
402
+ <span class="ruby-identifier">filename</span> = <span class="ruby-identifier">dir</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'/'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">filename</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">!=</span> <span class="ruby-value str">'.'</span>
403
+ <span class="ruby-keyword kw">end</span>
385
404
  <span class="ruby-identifier">test</span>(<span class="ruby-value">?f</span>, <span class="ruby-identifier">filename</span>) <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-identifier">parse_error</span>(<span class="ruby-node">&quot;'#{filename}': import file not found.&quot;</span>)
386
405
  <span class="ruby-identifier">c</span> = <span class="ruby-ivar">@ch</span>
387
406
  <span class="ruby-identifier">c</span> = <span class="ruby-identifier">getch</span>() <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">is_whitespace</span>(<span class="ruby-identifier">c</span>)
@@ -397,21 +416,24 @@ example of presentation logic in css style:
397
416
  </div>
398
417
  </div>
399
418
 
400
- <div id="method-M000039" class="method-detail">
401
- <a name="M000039"></a>
419
+ <div id="method-M000075" class="method-detail">
420
+ <a name="M000075"></a>
402
421
 
403
422
  <div class="method-heading">
404
- <a href="#M000039" class="method-signature">
423
+ <a href="#M000075" class="method-signature">
405
424
  <span class="method-name">scan_hook</span><span class="method-args">()</span>
406
425
  </a>
407
426
  </div>
408
427
 
409
428
  <div class="method-description">
429
+ <p>
430
+ return false when not hooked
431
+ </p>
410
432
  <p><a class="source-toggle" href="#"
411
- onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
412
- <div class="method-source-code" id="M000039-source">
433
+ onclick="toggleCode('M000075-source');return false;">[Source]</a></p>
434
+ <div class="method-source-code" id="M000075-source">
413
435
  <pre>
414
- <span class="ruby-comment cmt"># File kwartz/parser.rb, line 630</span>
436
+ <span class="ruby-comment cmt"># File kwartz/parser.rb, line 638</span>
415
437
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">scan_hook</span>
416
438
  <span class="ruby-comment cmt">## comment</span>
417
439
  <span class="ruby-identifier">c</span> = <span class="ruby-ivar">@ch</span>
@@ -460,7 +482,7 @@ example of presentation logic in css style:
460
482
  <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@token</span> = <span class="ruby-value">?@</span>
461
483
  <span class="ruby-keyword kw">end</span>
462
484
 
463
- <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
485
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
464
486
 
465
487
  <span class="ruby-keyword kw">end</span>
466
488
  </pre>
@@ -0,0 +1,313 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Module: Kwartz::Defun</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">Kwartz::Defun</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/kwartz/defun_rb.html">
59
+ kwartz/defun.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ </table>
66
+ </div>
67
+ <!-- banner header -->
68
+
69
+ <div id="bodyContent">
70
+
71
+
72
+
73
+ <div id="contextContent">
74
+
75
+ <div id="description">
76
+ <p>
77
+ generate compiled code. see defun() method for usage.
78
+ </p>
79
+
80
+ </div>
81
+
82
+
83
+ </div>
84
+
85
+ <div id="method-list">
86
+ <h3 class="section-bar">Methods</h3>
87
+
88
+ <div class="name-list">
89
+ <a href="#M000014">build_defun_code</a>&nbsp;&nbsp;
90
+ <a href="#M000016">build_php_code</a>&nbsp;&nbsp;
91
+ <a href="#M000015">build_ruby_code</a>&nbsp;&nbsp;
92
+ <a href="#M000013">compile_into_lang_code</a>&nbsp;&nbsp;
93
+ <a href="#M000012">defun</a>&nbsp;&nbsp;
94
+ </div>
95
+ </div>
96
+
97
+ </div>
98
+
99
+
100
+ <!-- if includes -->
101
+
102
+ <div id="section">
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+ <!-- if method_list -->
112
+ <div id="methods">
113
+ <h3 class="section-bar">Public Instance methods</h3>
114
+
115
+ <div id="method-M000014" class="method-detail">
116
+ <a name="M000014"></a>
117
+
118
+ <div class="method-heading">
119
+ <a href="#M000014" class="method-signature">
120
+ <span class="method-name">build_defun_code</span><span class="method-args">(basename, code, lang, properties)</span>
121
+ </a>
122
+ </div>
123
+
124
+ <div class="method-description">
125
+ <p><a class="source-toggle" href="#"
126
+ onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
127
+ <div class="method-source-code" id="M000014-source">
128
+ <pre>
129
+ <span class="ruby-comment cmt"># File kwartz/defun.rb, line 63</span>
130
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">build_defun_code</span>(<span class="ruby-identifier">basename</span>, <span class="ruby-identifier">code</span>, <span class="ruby-identifier">lang</span>, <span class="ruby-identifier">properties</span>)
131
+ <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">lang</span>
132
+ <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'ruby'</span>, <span class="ruby-value str">'eruby'</span>, <span class="ruby-value str">'rails'</span>, <span class="ruby-value str">'erubis'</span>, <span class="ruby-value str">'pierubis'</span>
133
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">build_ruby_code</span>(<span class="ruby-identifier">basename</span>, <span class="ruby-identifier">code</span>, <span class="ruby-identifier">properties</span>)
134
+ <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'php'</span>
135
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">build_php_code</span>(<span class="ruby-identifier">basename</span>, <span class="ruby-identifier">code</span>, <span class="ruby-identifier">properties</span>)
136
+ <span class="ruby-keyword kw">else</span>
137
+ <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;'#{lang}': not supported language.&quot;</span>
138
+ <span class="ruby-keyword kw">end</span>
139
+ <span class="ruby-keyword kw">end</span>
140
+ </pre>
141
+ </div>
142
+ </div>
143
+ </div>
144
+
145
+ <div id="method-M000016" class="method-detail">
146
+ <a name="M000016"></a>
147
+
148
+ <div class="method-heading">
149
+ <a href="#M000016" class="method-signature">
150
+ <span class="method-name">build_php_code</span><span class="method-args">(basename, php_code, properties)</span>
151
+ </a>
152
+ </div>
153
+
154
+ <div class="method-description">
155
+ <p><a class="source-toggle" href="#"
156
+ onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
157
+ <div class="method-source-code" id="M000016-source">
158
+ <pre>
159
+ <span class="ruby-comment cmt"># File kwartz/defun.rb, line 103</span>
160
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">build_php_code</span>(<span class="ruby-identifier">basename</span>, <span class="ruby-identifier">php_code</span>, <span class="ruby-identifier">properties</span>)
161
+ <span class="ruby-identifier">basename</span> = <span class="ruby-identifier">basename</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/[^\w]/</span>, <span class="ruby-value str">'_'</span>)
162
+ <span class="ruby-identifier">s</span> = <span class="ruby-value str">&quot;&lt;?php\nfunction print_view_\#{basename}($context) {\n explode($context);\n?&gt;\#{php_code}&lt;?php\n}\nfunction expand_view_\#{basename}($context) {\n ob_start();\n print_view_\#{basename}($context);\n $output = ob_get_clean();\n ob_end_clean();\n return $output;\n}\n?&gt;\n&quot;</span>
163
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">s</span>
164
+ <span class="ruby-keyword kw">end</span>
165
+ </pre>
166
+ </div>
167
+ </div>
168
+ </div>
169
+
170
+ <div id="method-M000015" class="method-detail">
171
+ <a name="M000015"></a>
172
+
173
+ <div class="method-heading">
174
+ <a href="#M000015" class="method-signature">
175
+ <span class="method-name">build_ruby_code</span><span class="method-args">(basename, ruby_code, properties)</span>
176
+ </a>
177
+ </div>
178
+
179
+ <div class="method-description">
180
+ <p><a class="source-toggle" href="#"
181
+ onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
182
+ <div class="method-source-code" id="M000015-source">
183
+ <pre>
184
+ <span class="ruby-comment cmt"># File kwartz/defun.rb, line 75</span>
185
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">build_ruby_code</span>(<span class="ruby-identifier">basename</span>, <span class="ruby-identifier">ruby_code</span>, <span class="ruby-identifier">properties</span>)
186
+ <span class="ruby-identifier">basename</span> = <span class="ruby-identifier">basename</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/[^\w]/</span>, <span class="ruby-value str">'_'</span>)
187
+ <span class="ruby-identifier">module_name</span> = <span class="ruby-identifier">properties</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">:module</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:module</span>] <span class="ruby-operator">:</span> <span class="ruby-value str">'View'</span>
188
+ <span class="ruby-identifier">method_verb</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:verb</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">'expand'</span>
189
+ <span class="ruby-identifier">method_name</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:method</span>] <span class="ruby-operator">||</span> <span class="ruby-node">&quot;#{method_verb}_#{basename}&quot;</span>
190
+ <span class="ruby-identifier">s</span> = <span class="ruby-value str">''</span>
191
+ <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;module #{module_name}\n&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">module_name</span>
192
+ <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;\n&quot;</span>
193
+ <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; (@@proc_table ||= {})['#{basename}'] = proc do\n&quot;</span>
194
+ <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">ruby_code</span> <span class="ruby-operator">&lt;&lt;</span> (<span class="ruby-operator">!</span><span class="ruby-identifier">ruby_code</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">ruby_code</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">!=</span> <span class="ruby-value">?\n</span> <span class="ruby-operator">?</span> <span class="ruby-value str">&quot;\n&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-value str">''</span>)
195
+ <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot; end#proc\n&quot;</span>
196
+ <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;\n&quot;</span>
197
+ <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot; module_function\n&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">module_name</span>
198
+ <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; def #{method_name}(context={})\n&quot;</span>
199
+ <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot; if context.is_a?(Hash)\n&quot;</span>
200
+ <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot; hash = context\n&quot;</span>
201
+ <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot; context = Object.new\n&quot;</span>
202
+ <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot; hash.each { |key, val| context.instance_variable_set(\&quot;@\#{key}\&quot;, val) }\n&quot;</span>
203
+ <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot; end\n&quot;</span>
204
+ <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; proc_obj = @@proc_table['#{basename}']\n&quot;</span>
205
+ <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot; context.instance_eval(&amp;proc_obj)\n&quot;</span>
206
+ <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot; end\n&quot;</span>
207
+ <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;\n&quot;</span>
208
+ <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;end\n&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">module_name</span>
209
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">s</span>
210
+ <span class="ruby-keyword kw">end</span>
211
+ </pre>
212
+ </div>
213
+ </div>
214
+ </div>
215
+
216
+ <div id="method-M000013" class="method-detail">
217
+ <a name="M000013"></a>
218
+
219
+ <div class="method-heading">
220
+ <a href="#M000013" class="method-signature">
221
+ <span class="method-name">compile_into_lang_code</span><span class="method-args">(output, lang, properties)</span>
222
+ </a>
223
+ </div>
224
+
225
+ <div class="method-description">
226
+ <p><a class="source-toggle" href="#"
227
+ onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
228
+ <div class="method-source-code" id="M000013-source">
229
+ <pre>
230
+ <span class="ruby-comment cmt"># File kwartz/defun.rb, line 41</span>
231
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">compile_into_lang_code</span>(<span class="ruby-identifier">output</span>, <span class="ruby-identifier">lang</span>, <span class="ruby-identifier">properties</span>)
232
+ <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">lang</span>
233
+ <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'ruby'</span>
234
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">output</span>
235
+ <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'eruby'</span>, <span class="ruby-value str">'rails'</span>
236
+ <span class="ruby-identifier">require</span> <span class="ruby-value str">'erb'</span>
237
+ <span class="ruby-identifier">trim_mode</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:trim_mode</span>] <span class="ruby-operator">||</span> (<span class="ruby-identifier">lang</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'eruby'</span> <span class="ruby-operator">?</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'-'</span>)
238
+ <span class="ruby-keyword kw">return</span> <span class="ruby-constant">ERB</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">output</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">trim_mode</span>).<span class="ruby-identifier">src</span>
239
+ <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'erubis'</span>
240
+ <span class="ruby-identifier">require</span> <span class="ruby-value str">'erubis'</span>
241
+ <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Erubis</span><span class="ruby-operator">::</span><span class="ruby-constant">Eruby</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">properties</span>).<span class="ruby-identifier">convert</span>(<span class="ruby-identifier">output</span>)
242
+ <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'pierubis'</span>
243
+ <span class="ruby-identifier">require</span> <span class="ruby-value str">'erubis'</span>
244
+ <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Erubis</span><span class="ruby-operator">::</span><span class="ruby-constant">PI</span><span class="ruby-operator">::</span><span class="ruby-constant">Eruby</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">properties</span>).<span class="ruby-identifier">convert</span>(<span class="ruby-identifier">output</span>)
245
+ <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'php'</span>
246
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">output</span>
247
+ <span class="ruby-keyword kw">else</span>
248
+ <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;'#{lang}': not supported language.&quot;</span>
249
+ <span class="ruby-keyword kw">end</span>
250
+ <span class="ruby-keyword kw">end</span>
251
+ </pre>
252
+ </div>
253
+ </div>
254
+ </div>
255
+
256
+ <div id="method-M000012" class="method-detail">
257
+ <a name="M000012"></a>
258
+
259
+ <div class="method-heading">
260
+ <a href="#M000012" class="method-signature">
261
+ <span class="method-name">defun</span><span class="method-args">(basename, output, lang, properties={})</span>
262
+ </a>
263
+ </div>
264
+
265
+ <div class="method-description">
266
+ <p>
267
+ generate compiled code
268
+ </p>
269
+ <p>
270
+ ex.
271
+ </p>
272
+ <pre>
273
+ args = %w[-l eruby -p ex.plogic ex.html]
274
+ eruby_src = Kwartz::Main.new(args).execute()
275
+ properties = { :trim_mode=&gt;'&gt;' }
276
+ code = Kwartz::Defun.defun('ex', eruby_src, 'eruby', properties)
277
+ print code
278
+ </pre>
279
+ <p>
280
+ command-line properties:
281
+ </p>
282
+ <pre>
283
+ --module=name : module name (default 'View')
284
+ --method=name : method name (default 'expand_xxx')
285
+ </pre>
286
+ <p><a class="source-toggle" href="#"
287
+ onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
288
+ <div class="method-source-code" id="M000012-source">
289
+ <pre>
290
+ <span class="ruby-comment cmt"># File kwartz/defun.rb, line 34</span>
291
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">defun</span>(<span class="ruby-identifier">basename</span>, <span class="ruby-identifier">output</span>, <span class="ruby-identifier">lang</span>, <span class="ruby-identifier">properties</span>={})
292
+ <span class="ruby-identifier">lang_code</span> = <span class="ruby-identifier">compile_into_lang_code</span>(<span class="ruby-identifier">output</span>, <span class="ruby-identifier">lang</span>, <span class="ruby-identifier">properties</span>)
293
+ <span class="ruby-identifier">s</span> = <span class="ruby-identifier">build_defun_code</span>(<span class="ruby-identifier">basename</span>, <span class="ruby-identifier">lang_code</span>, <span class="ruby-identifier">lang</span>, <span class="ruby-identifier">properties</span>)
294
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">s</span>
295
+ <span class="ruby-keyword kw">end</span>
296
+ </pre>
297
+ </div>
298
+ </div>
299
+ </div>
300
+
301
+
302
+ </div>
303
+
304
+
305
+ </div>
306
+
307
+
308
+ <div id="validator-badges">
309
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
310
+ </div>
311
+
312
+ </body>
313
+ </html>