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
@@ -1,121 +1,28 @@
1
1
  ###
2
- ### $Rev: 112 $
3
- ### $Release: 3.0.0 $
2
+ ### $Rev: 136 $
3
+ ### $Release: 3.1.0 $
4
4
  ### copyright(c) 2004-2006 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
7
7
  require "#{File.dirname(__FILE__)}/test.rb"
8
8
 
9
-
10
- PDATA = <<END
11
- <html>
12
- <body>
13
- <h1 id="doctitle">hoge</h1>
14
- <table id="content">
15
- <tr id="mark:list">
16
- <td id="mark:item">item</td>
17
- </tr>
18
- </table>
19
- </body>
20
- </html>
21
- END
22
-
23
-
24
- ERUBY_PLOGIC = <<END
25
- #doctitle {
26
- value: @title;
27
- remove: "id";
28
- }
29
- #list {
30
- logic: {
31
- for item in @list
32
- _elem
33
- end
34
- }
35
- }
36
- #item {
37
- Value: item;
38
- }
39
- END
40
-
41
-
42
- ERUBY_OUTPUT = <<END
43
- <html>
44
- <body>
45
- <h1><%= @title %></h1>
46
- <table id="content">
47
- <% for item in @list %>
48
- <tr>
49
- <td><%=h item %></td>
50
- </tr>
51
- <% end %>
52
- </table>
53
- </body>
54
- </html>
55
- END
56
-
57
-
58
- PHP_PLOGIC = <<END
59
- #doctitle {
60
- value: $title;
61
- remove: "id";
62
- }
63
- #list {
64
- logic: {
65
- foreach ($list as $item) {
66
- _elem();
67
- }
68
- }
69
- }
70
- #item {
71
- Value: $item;
72
- }
73
- END
74
-
75
-
76
- PHP_OUTPUT = <<END
77
- <html>
78
- <body>
79
- <h1><?php echo $title; ?></h1>
80
- <table id="content">
81
- <?php foreach ($list as $item) { ?>
82
- <tr>
83
- <td><?php echo htmlspecialchars($item); ?></td>
84
- </tr>
85
- <?php } ?>
86
- </table>
87
- </body>
88
- </html>
89
- END
90
-
91
-
92
- YAML_DATA = <<END
93
- title: kwartz example
94
- list:
95
- - <aaa>
96
- - b&b
97
- - '"ccc"'
98
- END
99
-
100
- YAML_OUTPUT = <<END
101
- <html>
102
- <body>
103
- <h1>kwartz example</h1>
104
- <table id="content">
105
- <tr>
106
- <td>&lt;aaa&gt;</td>
107
- </tr>
108
- <tr>
109
- <td>b&amp;b</td>
110
- </tr>
111
- <tr>
112
- <td>&quot;ccc&quot;</td>
113
- </tr>
114
- </table>
115
- </body>
116
- </html>
117
- END
118
-
9
+ filename = __FILE__.sub(/\.\w+$/, '.yaml')
10
+ ydoc = YAML.load_file(filename)
11
+
12
+ PDATA = ydoc['pdata']
13
+ ERUBY_PLOGIC = ydoc['plogic*']['eruby']
14
+ ERUBY_OUTPUT = ydoc['expected*']['eruby']
15
+ PHP_PLOGIC = ydoc['plogic*']['php']
16
+ PHP_OUTPUT = ydoc['expected*']['php']
17
+ IMPORT_PDATA = ydoc['import_pdata']
18
+ IMPORT_PLOGIC = ydoc['import_plogic*']['eruby']
19
+ LAYOUT = ydoc['layout']
20
+ YAML_DATA = ydoc['yamldata']
21
+ YAML_OUTPUT = ydoc['yamloutput']
22
+ NOTEXT_ERUBY = ydoc['notext*']['eruby']
23
+ NOTEXT_RUBY = ydoc['notext*']['ruby']
24
+ DEFUN_ERUBY = ydoc['defun*']['eruby']
25
+ DEFUN_PHP = ydoc['defun*']['php']
119
26
 
120
27
  class File
121
28
  def self.write(filename, content)
@@ -133,6 +40,7 @@ class MainTest < Test::Unit::TestCase
133
40
 
134
41
  def _test
135
42
  @name = (caller()[0] =~ /in `test_(.*?)'/) && $1
43
+ return if ENV['TEST'] && ENV['TEST'] != @name
136
44
  begin
137
45
  File.write("#{@name}.pdata", @pdata) if @pdata
138
46
  File.write("#{@name}.plogic", @plogic) if @plogic
@@ -261,18 +169,8 @@ class MainTest < Test::Unit::TestCase
261
169
  @pdata = PDATA
262
170
  @plogic = ERUBY_PLOGIC.sub(/^\#doctitle.*?\}/m, "#doctitle{logic:{\n_element(sectitle)\n}\n}")
263
171
  @expected = ERUBY_OUTPUT.sub(/^\s*<h1>.*?<\/h1>/, '<%= sectitle %>')
264
- s = <<END
265
- <div>
266
- <span id="mark:sectitle">foo</span>
267
- </div>
268
- END
269
- File.write('import1a.pdata', s)
270
- s = <<END
271
- #sectitle {
272
- elem: sectitle;
273
- }
274
- END
275
- File.write('import1a.plogic', s)
172
+ File.write('import1a.pdata', IMPORT_PDATA)
173
+ File.write('import1a.plogic', IMPORT_PLOGIC)
276
174
  @argv = %w[-p import1,import1a -i import1a.pdata import1.pdata]
277
175
  begin
278
176
  _test
@@ -293,25 +191,9 @@ END
293
191
  # OK
294
192
  @pdata = PDATA
295
193
  @plogic = ERUBY_PLOGIC
296
- s = <<END
297
- <?xml version="1.0" charset="utf8"?>
298
- <html>
299
- <head>
300
- <title title="replace_content_with: content(doctitle)">layout file</title>
301
- </head>
302
- <body>
303
-
304
- <div title="replace_element_with: element(content)">
305
- foo
306
- bar
307
- </div>
308
-
309
- </body>
310
- </html>
311
- END
312
- File.write('layout.html', s)
194
+ File.write('layout.html', LAYOUT)
313
195
  content_str = (ERUBY_OUTPUT =~ /^\s*<table.*?<\/table>/m) && $&
314
- @expected = s.sub(/^(\s*)<title.*?<\/title>/, '\1<title><%= @title %></title>')
196
+ @expected = LAYOUT.sub(/^(\s*)<title.*?<\/title>/, '\1<title><%= @title %></title>')
315
197
  @expected.sub!(/^( *)<div .*?<\/div>/m, content_str)
316
198
  @argv = %w[-p layout1 -L layout.html layout1.pdata]
317
199
  begin
@@ -398,14 +280,15 @@ END
398
280
  # NG
399
281
  @argv = %w[-f untabify1.yaml -p untabify1 untabify1.pdata]
400
282
  @exception = ArgumentError # yaml syntax error
283
+ _test
401
284
  end
402
285
 
403
286
 
404
287
  def test_intern1 # -S
405
288
  # OK
406
289
  @pdata = <<END
407
- <span title="value: @aaa[:bb1][:cc1][:dd1]">xxx</span>
408
- <span title="value: @aaa[:bb1][:cc1][:dd2][:bb2]">xxx</span>
290
+ <span kw:d="value: @aaa[:bb1][:cc1][:dd1]">xxx</span>
291
+ <span kw:d="value: @aaa[:bb1][:cc1][:dd2][:bb2]">xxx</span>
409
292
  END
410
293
  @yamldata = <<END
411
294
  aaa: &anchor1
@@ -423,19 +306,51 @@ END
423
306
  _test
424
307
  # OK
425
308
  @pdata = <<END
426
- <span title="value: @aaa['bb1']['cc1']['dd1']">xxx</span>
427
- <span title="value: @aaa['bb1']['cc1']['dd2']['bb2']">xxx</span>
309
+ <span kw:d="value: @aaa['bb1']['cc1']['dd1']">xxx</span>
310
+ <span kw:d="value: @aaa['bb1']['cc1']['dd2']['bb2']">xxx</span>
428
311
  END
429
312
  @argv = %w[-tf intern1.yaml intern1.pdata]
430
313
  _test
431
314
  end
432
315
 
433
316
 
317
+ def test_defun1 # -a defun
318
+ @argv = %w[-a defun -p defun1 defun1.pdata]
319
+ @pdata = PDATA
320
+ @plogic = ERUBY_PLOGIC
321
+ @lang = 'eruby'
322
+ @expected = DEFUN_ERUBY
323
+ _test
324
+ end
325
+
326
+
327
+ def test_defun2 # -a defun -l php
328
+ @argv = %w[-a defun -l php -p defun2 defun2.pdata]
329
+ @pdata = PDATA
330
+ @plogic = PHP_PLOGIC
331
+ @lang = 'php'
332
+ @expected = DEFUN_PHP
333
+ _test
334
+ end
335
+
336
+
337
+ def test_notext # -N
338
+ @argv = %w[-N -p notext notext.pdata]
339
+ @pdata = PDATA
340
+ @plogic = ERUBY_PLOGIC
341
+ @expected = NOTEXT_ERUBY
342
+ _test
343
+ @argv = %w[-lruby -N -p notext notext.pdata]
344
+ @expected = NOTEXT_RUBY
345
+ _test
346
+ end
347
+
434
348
  def test_no_args
435
349
  @exception = Kwartz::CommandOptionError
436
350
  tuples = [
437
351
  [?l, 'lang name'],
438
352
  [?k, 'kanji code'],
353
+ [?a, 'action name'],
439
354
  [?r, 'library name'],
440
355
  [?p, 'file name'],
441
356
  [?P, 'parser style'],
@@ -0,0 +1,235 @@
1
+ pdata: |
2
+ <html>
3
+ <body>
4
+ <h1 id="doctitle">hoge</h1>
5
+ <table id="content">
6
+ <tr id="mark:list">
7
+ <td id="mark:item">item</td>
8
+ </tr>
9
+ </table>
10
+ </body>
11
+ </html>
12
+
13
+ plogic*:
14
+ eruby: &plogic_ruby |
15
+ #doctitle {
16
+ value: @title;
17
+ remove: "id";
18
+ }
19
+ #list {
20
+ logic: {
21
+ for item in @list
22
+ _elem
23
+ end
24
+ }
25
+ }
26
+ #item {
27
+ Value: item;
28
+ }
29
+
30
+ ruby: *plogic_ruby
31
+
32
+ php: |
33
+ #doctitle {
34
+ value: $title;
35
+ remove: "id";
36
+ }
37
+ #list {
38
+ logic: {
39
+ foreach ($list as $item) {
40
+ _elem();
41
+ }
42
+ }
43
+ }
44
+ #item {
45
+ Value: $item;
46
+ }
47
+
48
+ expected*:
49
+ eruby: |
50
+ <html>
51
+ <body>
52
+ <h1><%= @title %></h1>
53
+ <table id="content">
54
+ <% for item in @list %>
55
+ <tr>
56
+ <td><%=h item %></td>
57
+ </tr>
58
+ <% end %>
59
+ </table>
60
+ </body>
61
+ </html>
62
+
63
+ ruby: |
64
+ _buf = ""; _buf << "<html>
65
+ <body>
66
+ <h1>"; _buf << (@title).to_s; _buf << "</h1>
67
+ <table id=\"content\">\n";
68
+ for item in @list
69
+ _buf << " <tr>
70
+ <td>"; _buf << ERB::Util.h(item); _buf << "</td>
71
+ </tr>\n";
72
+ end
73
+ _buf << " </table>
74
+ </body>
75
+ </html>\n";
76
+ ; _buf
77
+
78
+ php: |
79
+ <html>
80
+ <body>
81
+ <h1><?php echo $title; ?></h1>
82
+ <table id="content">
83
+ <?php foreach ($list as $item) { ?>
84
+ <tr>
85
+ <td><?php echo htmlspecialchars($item); ?></td>
86
+ </tr>
87
+ <?php } ?>
88
+ </table>
89
+ </body>
90
+ </html>
91
+
92
+ notext*:
93
+ eruby: |4+
94
+
95
+
96
+ <%= @title %>
97
+
98
+ <% for item in @list %>
99
+
100
+ <%=h item %>
101
+
102
+ <% end %>
103
+
104
+
105
+
106
+ ruby: |
107
+ _buf = "";
108
+
109
+ _buf << (@title).to_s;
110
+
111
+ for item in @list
112
+
113
+ _buf << ERB::Util.h(item);
114
+
115
+ end
116
+
117
+
118
+
119
+ ; _buf
120
+
121
+ import_pdata: |
122
+ <div>
123
+ <span id="mark:sectitle">foo</span>
124
+ </div>
125
+
126
+ import_plogic*:
127
+ eruby: |
128
+ #sectitle{
129
+ elem: sectitle;
130
+ }
131
+ php: |
132
+ #sectitle{
133
+ elem: $sectitle;
134
+ }
135
+
136
+ layout: |
137
+ <?xml version="1.0" charset="utf8"?>
138
+ <html>
139
+ <head>
140
+ <title id="replace_content_with_content:doctitle">layout file</title>
141
+ </head>
142
+ <body>
143
+
144
+ <div id="replace_element_with_element:content">
145
+ foo
146
+ bar
147
+ </div>
148
+
149
+ </body>
150
+ </html>
151
+
152
+ yamldata: |
153
+ title: kwartz example
154
+ list:
155
+ - <aaa>
156
+ - b&b
157
+ - '"ccc"'
158
+
159
+ yamloutput: |
160
+ <html>
161
+ <body>
162
+ <h1>kwartz example</h1>
163
+ <table id="content">
164
+ <tr>
165
+ <td>&lt;aaa&gt;</td>
166
+ </tr>
167
+ <tr>
168
+ <td>b&amp;b</td>
169
+ </tr>
170
+ <tr>
171
+ <td>&quot;ccc&quot;</td>
172
+ </tr>
173
+ </table>
174
+ </body>
175
+ </html>
176
+
177
+ defun*:
178
+ eruby: |
179
+ module View
180
+
181
+ (@@proc_table ||= {})['defun1'] = proc do
182
+ _erbout = ''; _erbout.concat "<html>\n"
183
+ _erbout.concat " <body>\n"
184
+ _erbout.concat " <h1>"; _erbout.concat(( @title ).to_s); _erbout.concat "</h1>\n"
185
+ _erbout.concat " <table id=\"content\">\n"
186
+ for item in @list
187
+ _erbout.concat " <tr>\n"
188
+ _erbout.concat " <td>"; _erbout.concat((h item ).to_s); _erbout.concat "</td>\n"
189
+ _erbout.concat " </tr>\n"
190
+ end
191
+ _erbout.concat " </table>\n"
192
+ _erbout.concat " </body>\n"
193
+ _erbout.concat "</html>\n"
194
+ _erbout
195
+ end#proc
196
+
197
+ module_function
198
+ def expand_defun1(context={})
199
+ if context.is_a?(Hash)
200
+ hash = context
201
+ context = Object.new
202
+ hash.each { |key, val| context.instance_variable_set("@#{key}", val) }
203
+ end
204
+ proc_obj = @@proc_table['defun1']
205
+ context.instance_eval(&proc_obj)
206
+ end
207
+
208
+ end
209
+
210
+ php: |
211
+ <?php
212
+ function print_view_defun2($context) {
213
+ explode($context);
214
+ ?><html>
215
+ <body>
216
+ <h1><?php echo $title; ?></h1>
217
+ <table id="content">
218
+ <?php foreach ($list as $item) { ?>
219
+ <tr>
220
+ <td><?php echo htmlspecialchars($item); ?></td>
221
+ </tr>
222
+ <?php } ?>
223
+ </table>
224
+ </body>
225
+ </html>
226
+ <?php
227
+ }
228
+ function expand_view_defun2($context) {
229
+ ob_start();
230
+ print_view_defun2($context);
231
+ $output = ob_get_clean();
232
+ ob_end_clean();
233
+ return $output;
234
+ }
235
+ ?>