erbse 0.0.1 → 0.0.2

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 (159) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +3 -0
  3. data/Gemfile +3 -0
  4. data/README.md +40 -22
  5. data/Rakefile +13 -0
  6. data/lib/erbse.rb +3 -6
  7. data/lib/erbse/converter.rb +41 -241
  8. data/lib/erbse/eruby.rb +114 -0
  9. data/lib/erbse/template.rb +14 -0
  10. data/lib/erbse/version.rb +1 -1
  11. data/test/erbse_test.rb +14 -0
  12. data/test/test_helper.rb +2 -0
  13. metadata +9 -149
  14. data/CHANGES.txt +0 -828
  15. data/bin/erubis +0 -10
  16. data/lib/erbse/context.rb +0 -83
  17. data/lib/erbse/engine.rb +0 -114
  18. data/lib/erbse/engine/ec.rb +0 -117
  19. data/lib/erbse/engine/ecpp.rb +0 -113
  20. data/lib/erbse/engine/ejava.rb +0 -110
  21. data/lib/erbse/engine/ejavascript.rb +0 -119
  22. data/lib/erbse/engine/enhanced.rb +0 -126
  23. data/lib/erbse/engine/eperl.rb +0 -95
  24. data/lib/erbse/engine/ephp.rb +0 -99
  25. data/lib/erbse/engine/eruby.rb +0 -119
  26. data/lib/erbse/engine/escheme.rb +0 -114
  27. data/lib/erbse/engine/optimized.rb +0 -127
  28. data/lib/erbse/enhancer.rb +0 -723
  29. data/lib/erbse/error.rb +0 -23
  30. data/lib/erbse/evaluator.rb +0 -88
  31. data/lib/erbse/generator.rb +0 -85
  32. data/lib/erbse/helper.rb +0 -47
  33. data/lib/erbse/helpers/rails_form_helper.rb +0 -197
  34. data/lib/erbse/helpers/rails_helper.rb +0 -353
  35. data/lib/erbse/main.rb +0 -516
  36. data/lib/erbse/preprocessing.rb +0 -58
  37. data/lib/erbse/tiny.rb +0 -144
  38. data/lib/erbse/util.rb +0 -22
  39. data/test/assert-text-equal.rb +0 -44
  40. data/test/data/users-guide/Example.ejava +0 -55
  41. data/test/data/users-guide/array_example.result +0 -9
  42. data/test/data/users-guide/arraybuffer_example.result +0 -9
  43. data/test/data/users-guide/bipattern-example.rhtml +0 -4
  44. data/test/data/users-guide/bipattern_example.result +0 -6
  45. data/test/data/users-guide/bufvar-example.rb +0 -10
  46. data/test/data/users-guide/bufvar-example.result +0 -17
  47. data/test/data/users-guide/context.rb +0 -6
  48. data/test/data/users-guide/context.yaml +0 -8
  49. data/test/data/users-guide/def_method.rb +0 -14
  50. data/test/data/users-guide/def_method.result +0 -3
  51. data/test/data/users-guide/escape_example.result +0 -9
  52. data/test/data/users-guide/example.ec +0 -27
  53. data/test/data/users-guide/example.ecpp +0 -30
  54. data/test/data/users-guide/example.ejs +0 -20
  55. data/test/data/users-guide/example.eperl +0 -18
  56. data/test/data/users-guide/example.ephp +0 -18
  57. data/test/data/users-guide/example.eruby +0 -6
  58. data/test/data/users-guide/example.escheme +0 -28
  59. data/test/data/users-guide/example1.eruby +0 -6
  60. data/test/data/users-guide/example1.rb +0 -17
  61. data/test/data/users-guide/example1.result +0 -16
  62. data/test/data/users-guide/example10.rb +0 -4
  63. data/test/data/users-guide/example10.result +0 -17
  64. data/test/data/users-guide/example10.xhtml +0 -14
  65. data/test/data/users-guide/example10_x.result +0 -17
  66. data/test/data/users-guide/example11.php +0 -20
  67. data/test/data/users-guide/example11.result +0 -23
  68. data/test/data/users-guide/example11.rhtml +0 -21
  69. data/test/data/users-guide/example11_C.result +0 -10
  70. data/test/data/users-guide/example11_N.result +0 -16
  71. data/test/data/users-guide/example11_U.result +0 -16
  72. data/test/data/users-guide/example11_php.result +0 -15
  73. data/test/data/users-guide/example1_x.result +0 -9
  74. data/test/data/users-guide/example2.eruby +0 -7
  75. data/test/data/users-guide/example2.rb +0 -10
  76. data/test/data/users-guide/example2.result +0 -27
  77. data/test/data/users-guide/example2_trim.result +0 -10
  78. data/test/data/users-guide/example2_x.result +0 -10
  79. data/test/data/users-guide/example3.eruby +0 -6
  80. data/test/data/users-guide/example3.rb +0 -10
  81. data/test/data/users-guide/example31.result +0 -22
  82. data/test/data/users-guide/example32.result +0 -4
  83. data/test/data/users-guide/example3_e.result +0 -8
  84. data/test/data/users-guide/example4.eruby +0 -3
  85. data/test/data/users-guide/example4.rb +0 -11
  86. data/test/data/users-guide/example4.result +0 -10
  87. data/test/data/users-guide/example4_x.result +0 -5
  88. data/test/data/users-guide/example5.eruby +0 -6
  89. data/test/data/users-guide/example5.rb +0 -16
  90. data/test/data/users-guide/example5.result +0 -7
  91. data/test/data/users-guide/example6.rb +0 -12
  92. data/test/data/users-guide/example6.result +0 -7
  93. data/test/data/users-guide/example7.eruby +0 -8
  94. data/test/data/users-guide/example71.result +0 -13
  95. data/test/data/users-guide/example72.result +0 -13
  96. data/test/data/users-guide/example8.eruby +0 -6
  97. data/test/data/users-guide/example8_ruby.result +0 -7
  98. data/test/data/users-guide/example8_yaml.result +0 -7
  99. data/test/data/users-guide/example9.eruby +0 -3
  100. data/test/data/users-guide/example9.rb +0 -8
  101. data/test/data/users-guide/example9.result +0 -9
  102. data/test/data/users-guide/example91.result +0 -5
  103. data/test/data/users-guide/example92.result +0 -4
  104. data/test/data/users-guide/example_c.result +0 -32
  105. data/test/data/users-guide/example_java.result +0 -56
  106. data/test/data/users-guide/example_js.result +0 -22
  107. data/test/data/users-guide/example_perl.result +0 -20
  108. data/test/data/users-guide/example_php.result +0 -19
  109. data/test/data/users-guide/example_scheme.result +0 -30
  110. data/test/data/users-guide/example_scheme_display.result +0 -29
  111. data/test/data/users-guide/fasteruby-example.rb +0 -8
  112. data/test/data/users-guide/fasteruby-example.result +0 -18
  113. data/test/data/users-guide/fasteruby.rb +0 -11
  114. data/test/data/users-guide/fasteruby.result +0 -38
  115. data/test/data/users-guide/fasteruby.rhtml +0 -15
  116. data/test/data/users-guide/headerfooter-example.eruby +0 -9
  117. data/test/data/users-guide/headerfooter-example2.rb +0 -8
  118. data/test/data/users-guide/headerfooter-example2.rhtml +0 -10
  119. data/test/data/users-guide/headerfooter_example.result +0 -11
  120. data/test/data/users-guide/headerfooter_example2.result +0 -13
  121. data/test/data/users-guide/interpolation_example.result +0 -9
  122. data/test/data/users-guide/main_program1.rb +0 -8
  123. data/test/data/users-guide/main_program1.result +0 -6
  124. data/test/data/users-guide/main_program2.rb +0 -8
  125. data/test/data/users-guide/main_program2.result +0 -6
  126. data/test/data/users-guide/nocode-example.eruby +0 -14
  127. data/test/data/users-guide/nocode-php.result +0 -20
  128. data/test/data/users-guide/nocode_example.result +0 -15
  129. data/test/data/users-guide/normal-eruby-test.eruby +0 -9
  130. data/test/data/users-guide/normal_eruby_test.result +0 -11
  131. data/test/data/users-guide/notext-example.eruby +0 -14
  132. data/test/data/users-guide/notext-example.php +0 -19
  133. data/test/data/users-guide/notext-php.result +0 -20
  134. data/test/data/users-guide/notext_example.result +0 -16
  135. data/test/data/users-guide/percentline-example.rhtml +0 -6
  136. data/test/data/users-guide/percentline_example.result +0 -9
  137. data/test/data/users-guide/prefixedline-example.rb +0 -9
  138. data/test/data/users-guide/prefixedline-example.rhtml +0 -6
  139. data/test/data/users-guide/prefixedline_example.result +0 -9
  140. data/test/data/users-guide/printenable_example.result +0 -4
  141. data/test/data/users-guide/printenabled-example.eruby +0 -3
  142. data/test/data/users-guide/printenabled-example.rb +0 -8
  143. data/test/data/users-guide/printstatement_example.result +0 -8
  144. data/test/data/users-guide/simplify_example.result +0 -9
  145. data/test/data/users-guide/stderr.log +0 -3
  146. data/test/data/users-guide/stdout_exmple.result +0 -9
  147. data/test/data/users-guide/stringbuffer_example.result +0 -9
  148. data/test/data/users-guide/tail_260.result +0 -4
  149. data/test/data/users-guide/tailnewline.rhtml +0 -3
  150. data/test/data/users-guide/template1.rhtml +0 -4
  151. data/test/data/users-guide/template2.rhtml +0 -4
  152. data/test/test-engines.rb +0 -425
  153. data/test/test-enhancers.rb +0 -646
  154. data/test/test-erubis.rb +0 -887
  155. data/test/test-index-cgi.rb +0 -191
  156. data/test/test-main.rb +0 -752
  157. data/test/test-users-guide.rb +0 -73
  158. data/test/test.rb +0 -45
  159. data/test/testutil.rb +0 -111
@@ -1,6 +0,0 @@
1
- <% for item in list %>
2
- <p><%= item %></p>
3
- <p><%== item %></p>
4
- <p><%=== item %></p>
5
-
6
- <% end %>
@@ -1,10 +0,0 @@
1
- require 'erubis'
2
- input = File.read('example3.eruby')
3
- eruby = Erubis::EscapedEruby.new(input) # or Erubis::XmlEruby
4
-
5
- puts "----- script source ---"
6
- puts eruby.src # print script source
7
-
8
- puts "----- result ----------"
9
- list = ['<aaa>', 'b&b', '"ccc"']
10
- puts eruby.result(binding()) # get result
@@ -1,22 +0,0 @@
1
- $ ruby example3.rb 2> stderr.log
2
- ----- script source ---
3
- _buf = ''; for item in list
4
- _buf << ' <p>'; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << '</p>
5
- <p>'; _buf << ( item ).to_s; _buf << '</p>
6
- <p>'; $stderr.puts("*** debug: item=#{(item).inspect}"); _buf << '</p>
7
-
8
- '; end
9
- _buf.to_s
10
- ----- result ----------
11
- <p>&lt;aaa&gt;</p>
12
- <p><aaa></p>
13
- <p></p>
14
-
15
- <p>b&amp;b</p>
16
- <p>b&b</p>
17
- <p></p>
18
-
19
- <p>&quot;ccc&quot;</p>
20
- <p>"ccc"</p>
21
- <p></p>
22
-
@@ -1,4 +0,0 @@
1
- $ cat stderr.log
2
- *** debug: item="<aaa>"
3
- *** debug: item="b&b"
4
- *** debug: item="\"ccc\""
@@ -1,8 +0,0 @@
1
- $ erubis -l ruby -e example3.eruby
2
- _buf = ''; for item in list
3
- _buf << ' <p>'; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << '</p>
4
- <p>'; _buf << ( item ).to_s; _buf << '</p>
5
- <p>'; $stderr.puts("*** debug: item=#{(item).inspect}"); _buf << '</p>
6
-
7
- '; end
8
- _buf.to_s
@@ -1,3 +0,0 @@
1
- <!--% for item in list %-->
2
- <p><!--%= item %--></p>
3
- <!--% end %-->
@@ -1,11 +0,0 @@
1
- require 'erubis'
2
- input = File.read('example4.eruby')
3
- eruby = Erubis::Eruby.new(input, :pattern=>'<!--% %-->')
4
- # or '<(?:!--)?% %(?:--)?>'
5
-
6
- puts "---------- script source ---"
7
- puts eruby.src # print script source
8
-
9
- puts "---------- result ----------"
10
- list = ['aaa', 'bbb', 'ccc']
11
- puts eruby.result(binding()) # get result
@@ -1,10 +0,0 @@
1
- $ ruby example4.rb
2
- ---------- script source ---
3
- _buf = ''; for item in list
4
- _buf << ' <p>'; _buf << ( item ).to_s; _buf << '</p>
5
- '; end
6
- _buf.to_s
7
- ---------- result ----------
8
- <p>aaa</p>
9
- <p>bbb</p>
10
- <p>ccc</p>
@@ -1,5 +0,0 @@
1
- $ erubis -x -p '<!--% %-->' example4.eruby
2
- _buf = ''; for item in list
3
- _buf << ' <p>'; _buf << ( item ).to_s; _buf << '</p>
4
- '; end
5
- _buf.to_s
@@ -1,6 +0,0 @@
1
- <span><%= @val %></span>
2
- <ul>
3
- <% for item in @list %>
4
- <li><%= item %></li>
5
- <% end %>
6
- </ul>
@@ -1,16 +0,0 @@
1
- require 'erubis'
2
- input = File.read('example5.eruby')
3
- eruby = Erubis::Eruby.new(input) # create Eruby object
4
-
5
- ## create context object
6
- ## (key means var name, which may be string or symbol.)
7
- context = {
8
- :val => 'Erubis Example',
9
- 'list' => ['aaa', 'bbb', 'ccc'],
10
- }
11
- ## or
12
- # context = Erubis::Context.new()
13
- # context['val'] = 'Erubis Example'
14
- # context[:list] = ['aaa', 'bbb', 'ccc'],
15
-
16
- puts eruby.evaluate(context) # get result
@@ -1,7 +0,0 @@
1
- $ ruby example5.rb
2
- <span>Erubis Example</span>
3
- <ul>
4
- <li>aaa</li>
5
- <li>bbb</li>
6
- <li>ccc</li>
7
- </ul>
@@ -1,12 +0,0 @@
1
- class MyData
2
- attr_accessor :val, :list
3
- end
4
-
5
- ## any object can be a context object
6
- mydata = MyData.new
7
- mydata.val = 'Erubis Example'
8
- mydata.list = ['aaa', 'bbb', 'ccc']
9
-
10
- require 'erubis'
11
- eruby = Erubis::Eruby.new(File.read('example5.eruby'))
12
- puts eruby.evaluate(mydata)
@@ -1,7 +0,0 @@
1
- $ ruby example6.rb
2
- <span>Erubis Example</span>
3
- <ul>
4
- <li>aaa</li>
5
- <li>bbb</li>
6
- <li>ccc</li>
7
- </ul>
@@ -1,8 +0,0 @@
1
- <h1><%= @title %></h1>
2
- <ul>
3
- <% for user in @users %>
4
- <li>
5
- <a href="mailto:<%= user['mail']%>"><%= user['name'] %></a>
6
- </li>
7
- <% end %>
8
- </ul>
@@ -1,13 +0,0 @@
1
- $ erubis -f context.yaml example7.eruby
2
- <h1>Users List</h1>
3
- <ul>
4
- <li>
5
- <a href="mailto:foo@mail.com">foo</a>
6
- </li>
7
- <li>
8
- <a href="mailto:bar@mail.net">bar</a>
9
- </li>
10
- <li>
11
- <a href="mailto:baz@mail.org">baz</a>
12
- </li>
13
- </ul>
@@ -1,13 +0,0 @@
1
- $ erubis -f context.rb example7.eruby
2
- <h1>Users List</h1>
3
- <ul>
4
- <li>
5
- <a href="mailto:foo@mail.com">foo</a>
6
- </li>
7
- <li>
8
- <a href="mailto:bar@mail.net">bar</a>
9
- </li>
10
- <li>
11
- <a href="mailto:baz@mail.org">baz</a>
12
- </li>
13
- </ul>
@@ -1,6 +0,0 @@
1
- <h1><%= @title %></h1>
2
- <ul>
3
- <% for item in @list %>
4
- <li><%= item %></li>
5
- <% end %>
6
- </ul>
@@ -1,7 +0,0 @@
1
- $ erubis -c '@title="Example"; @list=%w[AAA BBB CCC]' example8.eruby
2
- <h1>Example</h1>
3
- <ul>
4
- <li>AAA</li>
5
- <li>BBB</li>
6
- <li>CCC</li>
7
- </ul>
@@ -1,7 +0,0 @@
1
- $ erubis -c '{title: Example, list: [AAA, BBB, CCC]}' example8.eruby
2
- <h1>Example</h1>
3
- <ul>
4
- <li>AAA</li>
5
- <li>BBB</li>
6
- <li>CCC</li>
7
- </ul>
@@ -1,3 +0,0 @@
1
- <% for item in @list %>
2
- <b><%= item %></b>
3
- <% end %>
@@ -1,8 +0,0 @@
1
- require 'erubis'
2
- input = File.read('example9.eruby')
3
- eruby1 = Erubis::Eruby.new(input)
4
- eruby2 = Erubis::Eruby.new(input, :preamble=>false, :postamble=>false)
5
-
6
- puts eruby1.src # print preamble and postamble
7
- puts "--------------"
8
- puts eruby2.src # don't print preamble and postamble
@@ -1,9 +0,0 @@
1
- $ ruby example9.rb
2
- _buf = ''; for item in @list
3
- _buf << ' <b>'; _buf << ( item ).to_s; _buf << '</b>
4
- '; end
5
- _buf.to_s
6
- --------------
7
- for item in @list
8
- _buf << ' <b>'; _buf << ( item ).to_s; _buf << '</b>
9
- '; end
@@ -1,5 +0,0 @@
1
- $ erubis -x example9.eruby
2
- _buf = ''; for item in @list
3
- _buf << ' <b>'; _buf << ( item ).to_s; _buf << '</b>
4
- '; end
5
- _buf.to_s
@@ -1,4 +0,0 @@
1
- $ erubis -x -b example9.eruby
2
- for item in @list
3
- _buf << ' <b>'; _buf << ( item ).to_s; _buf << '</b>
4
- '; end
@@ -1,32 +0,0 @@
1
- $ erubis -l cpp example.ecpp
2
- #line 1 "example.ecpp"
3
-
4
- #include <string>
5
- #include <iostream>
6
- #include <sstream>
7
-
8
- int main(int argc, char *argv[])
9
- {
10
- std::stringstream _buf;
11
-
12
- _buf << "<html>\n"
13
- " <body>\n"
14
- " <p>Hello "; _buf << (argv[0]); _buf << "!</p>\n"
15
- " <table>\n"
16
- " <tbody>\n";
17
- for (int i = 1; i < argc; i++) {
18
- _buf << " <tr bgcolor=\""; _buf << (i % 2 == 0 ? "#FFCCCC" : "#CCCCFF"); _buf << "\">\n"
19
- " <td>"; _buf << (i); _buf << "</td>\n"
20
- " <td>"; _buf << (argv[i]); _buf << "</td>\n"
21
- " </tr>\n";
22
- }
23
- _buf << " </tbody>\n"
24
- " </table>\n"
25
- " </body>\n"
26
- "</html>\n";
27
-
28
- std::string output = _buf.str();
29
- std::cout << output;
30
- return 0;
31
- }
32
-
@@ -1,56 +0,0 @@
1
- $ erubis -b -l java example.ejava
2
-
3
- import java.util.*;
4
-
5
- public class Example {
6
- private String user;
7
- private String[] list;
8
- public example(String user, String[] list) {
9
- this.user = user;
10
- this.list = list;
11
- }
12
-
13
- public String view() {
14
- StringBuffer _buf = new StringBuffer();
15
-
16
- _buf.append("<html>\n"
17
- + " <body>\n"
18
- + " <p>Hello "); _buf.append(user); _buf.append("!</p>\n"
19
- + " <table>\n"
20
- + " <tbody>\n");
21
- for (int i = 0; i < list.length; i++) {
22
- _buf.append(" <tr bgcolor=\""); _buf.append(i % 2 == 0 ? "#FFCCCC" : "#CCCCFF"); _buf.append("\">\n"
23
- + " <td>"); _buf.append(i + 1); _buf.append("</td>\n"
24
- + " <td>"); _buf.append(escape(list[i])); _buf.append("</td>\n"
25
- + " </tr>\n");
26
- }
27
- _buf.append(" </tbody>\n"
28
- + " </table>\n"
29
- + " <body>\n"
30
- + "</html>\n");
31
-
32
- return _buf.toString();
33
- }
34
-
35
- public static void main(String[] args) {
36
- String[] list = { "<aaa>", "b&b", "\"ccc\"" };
37
- Example ex = Example.new("Erubis", list);
38
- System.out.print(ex.view());
39
- }
40
-
41
- public static String escape(String s) {
42
- StringBuffer sb = new StringBuffer();
43
- for (int i = 0; i < s.length(); i++) {
44
- char ch = s.charAt(i);
45
- switch (ch) {
46
- case '<': sb.append("&lt;"); break;
47
- case '>': sb.append("&gt;"); break;
48
- case '&': sb.append("&amp;"); break;
49
- case '"': sb.append("&quot;"); break;
50
- default: sb.append(ch);
51
- }
52
- }
53
- return sb.toString();
54
- }
55
- }
56
-
@@ -1,22 +0,0 @@
1
- $ erubis -l js example.ejs
2
- var _buf = [];
3
- var user = 'Erubis';
4
- var list = ['<aaa>', 'b&b', '"ccc"'];
5
-
6
- _buf.push("<html>\n\
7
- <body>\n\
8
- <p>Hello "); _buf.push(user); _buf.push("!</p>\n\
9
- <table>\n\
10
- <tbody>\n");
11
- var i;
12
- for (i = 0; i < list.length; i++) {
13
- _buf.push(" <tr bgcolor=\""); _buf.push(i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'); _buf.push("\">\n\
14
- <td>"); _buf.push(i + 1); _buf.push("</td>\n\
15
- <td>"); _buf.push(list[i]); _buf.push("</td>\n\
16
- </tr>\n");
17
- }
18
- _buf.push(" </tbody>\n\
19
- </table>\n\
20
- </body>\n\
21
- </html>\n");
22
- document.write(_buf.join(""));
@@ -1,20 +0,0 @@
1
- $ erubis -l perl example.eperl
2
- use HTML::Entities;
3
- my $user = 'Erubis';
4
- my @list = ('<aaa>', 'b&b', '"ccc"');
5
-
6
- print('<html>
7
- <body>
8
- <p>Hello '); print($user); print('!</p>
9
- <table>
10
- '); $i = 0;
11
- for $item (@list) {
12
- print(' <tr bgcolor='); print(++$i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'); print('">
13
- <td>'); print($i); print('</td>
14
- <td>'); print($item); print('</td>
15
- </tr>
16
- '); }
17
- print(' </table>
18
- </body>
19
- </html>
20
- ');
@@ -1,19 +0,0 @@
1
- $ erubis -l php example.ephp
2
- <<?php ?>?xml version="1.0"?>
3
- <html>
4
- <body>
5
- <p>Hello <?php echo $user; ?>!</p>
6
- <table>
7
- <tbody>
8
- <?php $i = 0; ?>
9
- <?php foreach ($list as $item) { ?>
10
- <?php $i++; ?>
11
- <tr bgcolor="<?php echo $i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'; ?>">
12
- <td><?php echo $i; ?></td>
13
- <td><?php echo htmlspecialchars($item); ?></td>
14
- </tr>
15
- <?php } ?>
16
- </tbody>
17
- </table>
18
- </body>
19
- </html>
@@ -1,30 +0,0 @@
1
- $ erubis -l scheme example.escheme
2
- (let ((_buf '())) (define (_add x) (set! _buf (cons x _buf))) (_add "<html>
3
- <body>\n")
4
-
5
- (let ((user "Erubis")
6
- (items '("<aaa>" "b&b" "\"ccc\""))
7
- (i 0))
8
-
9
- (_add " <p>Hello ")(_add user)(_add "!</p>
10
- <table>\n")
11
-
12
- (for-each
13
- (lambda (item)
14
- (set! i (+ i 1))
15
-
16
- (_add " <tr bgcolor=\"")(_add (if (= (modulo i 2) 0) "#FFCCCC" "#CCCCFF"))(_add "\">
17
- <td>")(_add i)(_add "</td>
18
- <td>")(_add item)(_add "</td>
19
- </tr>\n")
20
-
21
- ) ; lambda end
22
- items) ; for-each end
23
-
24
- (_add " </table>\n")
25
-
26
- ) ; let end
27
-
28
- (_add " </body>
29
- </html>\n")
30
- (reverse _buf))
@@ -1,29 +0,0 @@
1
- $ erubis -l scheme --func=display example.escheme
2
- (display "<html>
3
- <body>\n")
4
-
5
- (let ((user "Erubis")
6
- (items '("<aaa>" "b&b" "\"ccc\""))
7
- (i 0))
8
-
9
- (display " <p>Hello ")(display user)(display "!</p>
10
- <table>\n")
11
-
12
- (for-each
13
- (lambda (item)
14
- (set! i (+ i 1))
15
-
16
- (display " <tr bgcolor=\"")(display (if (= (modulo i 2) 0) "#FFCCCC" "#CCCCFF"))(display "\">
17
- <td>")(display i)(display "</td>
18
- <td>")(display item)(display "</td>
19
- </tr>\n")
20
-
21
- ) ; lambda end
22
- items) ; for-each end
23
-
24
- (display " </table>\n")
25
-
26
- ) ; let end
27
-
28
- (display " </body>
29
- </html>\n")