erbse 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES.txt +828 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.md +51 -0
  5. data/benchmark/Makefile +6 -0
  6. data/benchmark/bench.rb +313 -0
  7. data/benchmark/bench_context.yaml +141 -0
  8. data/benchmark/templates/_footer.html +4 -0
  9. data/benchmark/templates/_header.html +52 -0
  10. data/benchmark/templates/bench_erb.rhtml +29 -0
  11. data/benchmark/templates/bench_erubis.rhtml +29 -0
  12. data/benchmark/templates/bench_eruby.rhtml +29 -0
  13. data/bin/erubis +10 -0
  14. data/erbse.gemspec +24 -0
  15. data/lib/erbse.rb +52 -0
  16. data/lib/erbse/context.rb +83 -0
  17. data/lib/erbse/converter.rb +357 -0
  18. data/lib/erbse/engine.rb +114 -0
  19. data/lib/erbse/engine/ec.rb +117 -0
  20. data/lib/erbse/engine/ecpp.rb +113 -0
  21. data/lib/erbse/engine/ejava.rb +110 -0
  22. data/lib/erbse/engine/ejavascript.rb +119 -0
  23. data/lib/erbse/engine/enhanced.rb +126 -0
  24. data/lib/erbse/engine/eperl.rb +95 -0
  25. data/lib/erbse/engine/ephp.rb +99 -0
  26. data/lib/erbse/engine/eruby.rb +119 -0
  27. data/lib/erbse/engine/escheme.rb +114 -0
  28. data/lib/erbse/engine/optimized.rb +127 -0
  29. data/lib/erbse/enhancer.rb +723 -0
  30. data/lib/erbse/error.rb +23 -0
  31. data/lib/erbse/evaluator.rb +88 -0
  32. data/lib/erbse/generator.rb +85 -0
  33. data/lib/erbse/helper.rb +47 -0
  34. data/lib/erbse/helpers/rails_form_helper.rb +197 -0
  35. data/lib/erbse/helpers/rails_helper.rb +353 -0
  36. data/lib/erbse/main.rb +516 -0
  37. data/lib/erbse/preprocessing.rb +58 -0
  38. data/lib/erbse/tiny.rb +144 -0
  39. data/lib/erbse/util.rb +22 -0
  40. data/lib/erbse/version.rb +3 -0
  41. data/test/assert-text-equal.rb +44 -0
  42. data/test/data/users-guide/Example.ejava +55 -0
  43. data/test/data/users-guide/array_example.result +9 -0
  44. data/test/data/users-guide/arraybuffer_example.result +9 -0
  45. data/test/data/users-guide/bipattern-example.rhtml +4 -0
  46. data/test/data/users-guide/bipattern_example.result +6 -0
  47. data/test/data/users-guide/bufvar-example.rb +10 -0
  48. data/test/data/users-guide/bufvar-example.result +17 -0
  49. data/test/data/users-guide/context.rb +6 -0
  50. data/test/data/users-guide/context.yaml +8 -0
  51. data/test/data/users-guide/def_method.rb +14 -0
  52. data/test/data/users-guide/def_method.result +3 -0
  53. data/test/data/users-guide/escape_example.result +9 -0
  54. data/test/data/users-guide/example.ec +27 -0
  55. data/test/data/users-guide/example.ecpp +30 -0
  56. data/test/data/users-guide/example.ejs +20 -0
  57. data/test/data/users-guide/example.eperl +18 -0
  58. data/test/data/users-guide/example.ephp +18 -0
  59. data/test/data/users-guide/example.eruby +6 -0
  60. data/test/data/users-guide/example.escheme +28 -0
  61. data/test/data/users-guide/example1.eruby +6 -0
  62. data/test/data/users-guide/example1.rb +17 -0
  63. data/test/data/users-guide/example1.result +16 -0
  64. data/test/data/users-guide/example10.rb +4 -0
  65. data/test/data/users-guide/example10.result +17 -0
  66. data/test/data/users-guide/example10.xhtml +14 -0
  67. data/test/data/users-guide/example10_x.result +17 -0
  68. data/test/data/users-guide/example11.php +20 -0
  69. data/test/data/users-guide/example11.result +23 -0
  70. data/test/data/users-guide/example11.rhtml +21 -0
  71. data/test/data/users-guide/example11_C.result +10 -0
  72. data/test/data/users-guide/example11_N.result +16 -0
  73. data/test/data/users-guide/example11_U.result +16 -0
  74. data/test/data/users-guide/example11_php.result +15 -0
  75. data/test/data/users-guide/example1_x.result +9 -0
  76. data/test/data/users-guide/example2.eruby +7 -0
  77. data/test/data/users-guide/example2.rb +10 -0
  78. data/test/data/users-guide/example2.result +27 -0
  79. data/test/data/users-guide/example2_trim.result +10 -0
  80. data/test/data/users-guide/example2_x.result +10 -0
  81. data/test/data/users-guide/example3.eruby +6 -0
  82. data/test/data/users-guide/example3.rb +10 -0
  83. data/test/data/users-guide/example31.result +22 -0
  84. data/test/data/users-guide/example32.result +4 -0
  85. data/test/data/users-guide/example3_e.result +8 -0
  86. data/test/data/users-guide/example4.eruby +3 -0
  87. data/test/data/users-guide/example4.rb +11 -0
  88. data/test/data/users-guide/example4.result +10 -0
  89. data/test/data/users-guide/example4_x.result +5 -0
  90. data/test/data/users-guide/example5.eruby +6 -0
  91. data/test/data/users-guide/example5.rb +16 -0
  92. data/test/data/users-guide/example5.result +7 -0
  93. data/test/data/users-guide/example6.rb +12 -0
  94. data/test/data/users-guide/example6.result +7 -0
  95. data/test/data/users-guide/example7.eruby +8 -0
  96. data/test/data/users-guide/example71.result +13 -0
  97. data/test/data/users-guide/example72.result +13 -0
  98. data/test/data/users-guide/example8.eruby +6 -0
  99. data/test/data/users-guide/example8_ruby.result +7 -0
  100. data/test/data/users-guide/example8_yaml.result +7 -0
  101. data/test/data/users-guide/example9.eruby +3 -0
  102. data/test/data/users-guide/example9.rb +8 -0
  103. data/test/data/users-guide/example9.result +9 -0
  104. data/test/data/users-guide/example91.result +5 -0
  105. data/test/data/users-guide/example92.result +4 -0
  106. data/test/data/users-guide/example_c.result +32 -0
  107. data/test/data/users-guide/example_java.result +56 -0
  108. data/test/data/users-guide/example_js.result +22 -0
  109. data/test/data/users-guide/example_perl.result +20 -0
  110. data/test/data/users-guide/example_php.result +19 -0
  111. data/test/data/users-guide/example_scheme.result +30 -0
  112. data/test/data/users-guide/example_scheme_display.result +29 -0
  113. data/test/data/users-guide/fasteruby-example.rb +8 -0
  114. data/test/data/users-guide/fasteruby-example.result +18 -0
  115. data/test/data/users-guide/fasteruby.rb +11 -0
  116. data/test/data/users-guide/fasteruby.result +38 -0
  117. data/test/data/users-guide/fasteruby.rhtml +15 -0
  118. data/test/data/users-guide/headerfooter-example.eruby +9 -0
  119. data/test/data/users-guide/headerfooter-example2.rb +8 -0
  120. data/test/data/users-guide/headerfooter-example2.rhtml +10 -0
  121. data/test/data/users-guide/headerfooter_example.result +11 -0
  122. data/test/data/users-guide/headerfooter_example2.result +13 -0
  123. data/test/data/users-guide/interpolation_example.result +9 -0
  124. data/test/data/users-guide/main_program1.rb +8 -0
  125. data/test/data/users-guide/main_program1.result +6 -0
  126. data/test/data/users-guide/main_program2.rb +8 -0
  127. data/test/data/users-guide/main_program2.result +6 -0
  128. data/test/data/users-guide/nocode-example.eruby +14 -0
  129. data/test/data/users-guide/nocode-php.result +20 -0
  130. data/test/data/users-guide/nocode_example.result +15 -0
  131. data/test/data/users-guide/normal-eruby-test.eruby +9 -0
  132. data/test/data/users-guide/normal_eruby_test.result +11 -0
  133. data/test/data/users-guide/notext-example.eruby +14 -0
  134. data/test/data/users-guide/notext-example.php +19 -0
  135. data/test/data/users-guide/notext-php.result +20 -0
  136. data/test/data/users-guide/notext_example.result +16 -0
  137. data/test/data/users-guide/percentline-example.rhtml +6 -0
  138. data/test/data/users-guide/percentline_example.result +9 -0
  139. data/test/data/users-guide/prefixedline-example.rb +9 -0
  140. data/test/data/users-guide/prefixedline-example.rhtml +6 -0
  141. data/test/data/users-guide/prefixedline_example.result +9 -0
  142. data/test/data/users-guide/printenable_example.result +4 -0
  143. data/test/data/users-guide/printenabled-example.eruby +3 -0
  144. data/test/data/users-guide/printenabled-example.rb +8 -0
  145. data/test/data/users-guide/printstatement_example.result +8 -0
  146. data/test/data/users-guide/simplify_example.result +9 -0
  147. data/test/data/users-guide/stderr.log +3 -0
  148. data/test/data/users-guide/stdout_exmple.result +9 -0
  149. data/test/data/users-guide/stringbuffer_example.result +9 -0
  150. data/test/data/users-guide/tail_260.result +4 -0
  151. data/test/data/users-guide/tailnewline.rhtml +3 -0
  152. data/test/data/users-guide/template1.rhtml +4 -0
  153. data/test/data/users-guide/template2.rhtml +4 -0
  154. data/test/test-engines.rb +425 -0
  155. data/test/test-enhancers.rb +646 -0
  156. data/test/test-erubis.rb +887 -0
  157. data/test/test-index-cgi.rb +191 -0
  158. data/test/test-main.rb +752 -0
  159. data/test/test-users-guide.rb +73 -0
  160. data/test/test.rb +45 -0
  161. data/test/testutil.rb +111 -0
  162. metadata +233 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8cc096d1012a8f395e01e9a7445d2bd23a3b8024
4
+ data.tar.gz: f8a42d194e45b147f5ee05c4d2fbab25aca5d231
5
+ SHA512:
6
+ metadata.gz: ccddec411ad1e76c807ae5b7abb38e5ecfd3e9feb6204748b4335706d85489bc9a24b050ecd59883454b57808ba4797c436133034dd12f51fb771025a247e3d5
7
+ data.tar.gz: 5937981a7f6f5847db0841aa32d2fe412da30cbb83e4b81753677e91349121f801150243080b5dce3d04e374578621e55f119bc79fd798d2dbddede370cb2479
@@ -0,0 +1,828 @@
1
+ # -*- coding: utf-8 -*-
2
+ # $Release: 2.7.0 $
3
+ # copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
4
+
5
+ - release: 2.7.0
6
+ date: 2011-04-01
7
+ enhancements:
8
+
9
+ - |
10
+ New option ':bufvar' supported to specify buffer variable name.
11
+
12
+ ex:
13
+ input = "Hello <%= name %>!"
14
+ eruby = Erubis::Eruby.new(input)
15
+ puts eruby.src
16
+ #=> _buf = ''; _buf << "Hello "; _buf << ( name ).to_s; _buf << '!';
17
+
18
+ eruby = Erubis::Eruby.new(input, :bufvar=>'@_out')
19
+ puts eruby.src
20
+ #=> @_out = ''; @_out << 'Hello '; @_out << ( name ).to_s; @_out << '!';
21
+
22
+ - |
23
+ New enhancer 'PrefixedLineEnhancer' which is a customizable version
24
+ of PercentLineEnhancer.
25
+ The difference between PrefixedLineEnhancer and PercentLineEnhancer is:
26
+ * You can indent Ruby statetment lines starting with '%'
27
+ * You can specify prefix character by :prefixchar option.
28
+
29
+ ex:
30
+ class MyEruby < Erubis::Eruby
31
+ include Erubis::PrefixedLineEnhancer
32
+ end
33
+ input = <<END
34
+ <ul>
35
+ % for item in @items
36
+ <li><%= item %></li>
37
+ % end
38
+ %% you can indent '%' lines
39
+ </ul>
40
+ END
41
+ eruby = MyEruby.new(input, :prefixchar=>'%') # default '%'
42
+ puts eruby.src
43
+
44
+ output:
45
+ _buf = ''; _buf << '<ul>
46
+ '; for item in @items
47
+ _buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
48
+ '; end
49
+ % you can indent '%' lines
50
+ _buf << '</ul>
51
+ ';
52
+ _buf.to_s
53
+
54
+ - |
55
+ Add helper CGI script. See 'public_html/README.txt' for details.
56
+
57
+ - |
58
+ Rubinius is supported as first-class Ruby implementation.
59
+
60
+ - |
61
+ C++ support. Try '-l cpp' command-line option.
62
+
63
+
64
+ changes:
65
+
66
+ - |
67
+ Remove dependency to 'abstract' library.
68
+ You don't need to install 'abstract' gem.
69
+
70
+ - |
71
+ Erubis::Eruby#load_file() now sets cache file timestamp to the same
72
+ value as original eRuby file. For example, if you restore eRuby files
73
+ from backup, Erubis::Eruby#load_file() can detect it and generate
74
+ cache file again.
75
+
76
+ ## generates cache file (A.rhtml.cache).
77
+ eruby = Erubis::Eruby.load_file('A.rhtml')
78
+ p File.mtime('A.rhtml') == File.mtime('A.rhtml.cache') #=> true
79
+
80
+
81
+
82
+ - release: 2.6.6
83
+ date: 2010-06-27
84
+ bugfixes:
85
+
86
+ - |
87
+ Fixed a bug around InterporationEnhancer and FastEruby to escape back-quote. (thanks to Andrew R Jackson)
88
+
89
+
90
+ - release: 2.6.5
91
+ date: 2009-07-20
92
+ bugfixes:
93
+
94
+ - |
95
+ Fixed bug around '-z' option.
96
+
97
+
98
+ - release: 2.6.4
99
+ date: 2009-02-18
100
+ enhancements:
101
+
102
+ - |
103
+ Rails 2.2 and 2.3 support.
104
+
105
+
106
+
107
+ - release: 2.6.3
108
+ date: 2009-02-07
109
+ bugfixes:
110
+
111
+ - Enhancer name was not displayed in Ruby 1.9.1 when it was missing.
112
+
113
+ - Command option argument name was not displayed correctly as a part of error message.
114
+
115
+ - MethoNotFound error was raised when invalid option was specified.
116
+
117
+
118
+ - release: 2.6.2
119
+ date: 2008-06-12
120
+ enhancements:
121
+
122
+ - |
123
+ Ruby 1.9 support.
124
+
125
+ bugfixes:
126
+
127
+ - |
128
+ Fixed installation problem on Windows (Thanks to Tim Morgan and Allen).
129
+
130
+
131
+ - release: 2.6.1
132
+ date: 2008-06-06
133
+ enhancements:
134
+
135
+ - |
136
+ Rails 2.1 support. (special thanks José Valim)
137
+
138
+
139
+
140
+ - release: 2.6.0
141
+ date: 2008-05-05
142
+ enhancements:
143
+
144
+ - |
145
+ Improved support of Ruby on Rails 2.0.2.
146
+ New class ActionView::TemplateHandlers::Erubis is defined and
147
+ registered as default handler of *.html.erb and *.rhtml.
148
+
149
+ - |
150
+ '<%% %>' and '<%%= %>' are converted into '<% %>' and '<%= %>' respectively.
151
+ This is for compatibility with ERB.
152
+
153
+ ex1.rhtml:
154
+ <ul>
155
+ <%% for item in @list %>
156
+ <li><%%= item %></li>
157
+ <%% end %>
158
+ </ul>
159
+
160
+ result:
161
+ $ erubis ex1.rhtml
162
+ <ul>
163
+ <% for item in @list %>
164
+ <li><%= item %></li>
165
+ <% end %>
166
+ </ul>
167
+
168
+ - |
169
+ '<%= -%>' removes tail spaces and newlines.
170
+ This is for compatibiliy with ERB when trim mode is '-'.
171
+ '<%= =%>' also removes tail spaces and newlines, and this is
172
+ Erubis-original enhancement (cooler than '<%= -%>', isn't it?).
173
+
174
+ ex2.rhtml:
175
+ <div>
176
+ <%= @var -%> # or <%= @var =%>
177
+ </div>
178
+
179
+ result (version 2.6.0):
180
+ $ erubis -c '{var: "AAA\n"}' ex2.rhtml
181
+ <div>
182
+ AAA
183
+ </div>
184
+
185
+ result (version 2.5.0):
186
+ $ erubis -c '{var: "AAA\n"}' ex2.rhtml
187
+ <div>
188
+ AAA
189
+
190
+ </div>
191
+
192
+ - |
193
+ Erubis::Eruby.load_file() now allows you to change cache filename.
194
+
195
+ ex.
196
+ eruby = Erubis::Eruby.load_file("ex3.rhtml",
197
+ :cachename=>'ex3.rhtml.cache')
198
+
199
+
200
+ - release: 2.5.0
201
+ date: 2008-01-30
202
+ enhancements:
203
+
204
+ - |
205
+ Ruby on Rails 2.0 support.
206
+ If you are using preprocessing, notice that _?('foo.id') will be NG
207
+ because it contains period ('.') character.
208
+
209
+ --------------------
210
+ <!-- NG in Rails 2.0 -->
211
+ [%= link_to 'Edit', edit_user_path(_?('@user.id')) %]
212
+ [%= link_to 'Show', @user %]
213
+ [%= link_to 'Delete', @user, :confirm=>'OK?', :method=>:delete %]
214
+
215
+ <!-- OK in Rails 2.0 -->
216
+ <%= user_id = @user.id %>
217
+ [%= link_to 'Edit', edit_user_path(_?('user_id')) %]
218
+ [%= link_to 'Show', :action=>'show', :id=>_?('user_id') %]
219
+ [%= link_to 'Delete', {:action=>'destroy', :id=>_?('user_id')},
220
+ {:confirm=>'OK?', :method=>:delete} %]
221
+ --------------------
222
+
223
+ - |
224
+ (experimental)
225
+ Rails form helper methods for preprocessing are added.
226
+ These helper methos are available with preprocessing.
227
+
228
+ ex. _form.rhtml
229
+ --------------------
230
+ Name: <%= text_field :user, :name %>
231
+ Name: [%= pp_text_field :user, :name %]
232
+ --------------------
233
+
234
+ preprocessed:
235
+ --------------------
236
+ Name: <%= text_field :user, :name %>
237
+ Name: <input id="stock_name" name="stock[name]" size="30" type="text" value="<%=h @stock.name%>" />
238
+ --------------------
239
+
240
+ Ruby code:
241
+ --------------------
242
+ _buf << '
243
+ Name: '; _buf << ( text_field :stock, :name ).to_s; _buf << '
244
+ Name: <input id="stock_name" name="stock[name]" size="30" type="text" value="'; _buf << (h @stock.name).to_s; _buf << '" />
245
+ ';
246
+ --------------------
247
+
248
+ This shows that text_filed() is called every time when rendering,
249
+ but pp_text_filed() is called only once when loading template,
250
+ so pp_text_field() with prepocessing is much faster than text_field().
251
+
252
+ See User's guide for details.
253
+ http://www.kuwata-lab.com/erubis/users-guide.05.html#rails-formhelpers
254
+
255
+ #
256
+ - release: 2.4.1
257
+ date: 2007-09-25
258
+ enhancements:
259
+
260
+ - |
261
+ Add new section 'evaluate(context) v.s. result(binding)' to user's guide.
262
+ This section describes why Erubis::Eruby#evaluate(context) is recommended
263
+ rather than Erubis::Eruby#result(binding).
264
+ User's Guide > Other Topics > evaluate(context) v.s. result(binding)
265
+ http://www.kuwata-lab.com/erubis/users-guide.06.html#topics-context-vs-binding
266
+
267
+ - |
268
+ Add new command-line property '--docwrite={true|false}' to
269
+ Erubis::Ejavascript.
270
+ If this property is true then 'document.write(_buf.join(""));' is used
271
+ as postamble and if it is false then '_buf.join("")' is used.
272
+ Default is true for compatibility reason but it will be false in the
273
+ future release.
274
+ (This feature was proposed by D.Dribin. Thank you.)
275
+
276
+ bugfix:
277
+
278
+ - |
279
+ When using Erubis::Eruby#evaluate(), changing local variables in
280
+ templates have affected to variables accessible with TOPLEVEL_BINDING.
281
+ It means that if you change variables in templates, it is possible to
282
+ change variables in main program.
283
+ This was a bug and is now fixed not to affect to variables in main
284
+ program.
285
+
286
+ ex. template.rhtml
287
+ --------------------
288
+ <% for x in @items %>
289
+ item = <%= x %>
290
+ <% end %>
291
+ --------------------
292
+
293
+ ex. main-program.rb
294
+ --------------------
295
+ require 'erubis'
296
+ x = 10
297
+ items = ['foo', 'bar', 'baz']
298
+ eruby = Erubis::Eruby.new(File.read('template.rhtml'))
299
+ s = eruby.evaluate(:items=>items)
300
+ print s
301
+ $stderr.puts "*** debug: x=#{x.inspect}" #=> x="baz" (2.4.0)
302
+ #=> x=10 (2.4.1)
303
+ --------------------
304
+
305
+ - |
306
+ PercentLineEnhancer was very slow. Now performance problem is solved.
307
+
308
+
309
+ #
310
+ - release: 2.4.0
311
+ date: 2007-07-19
312
+ enhancements:
313
+
314
+ - |
315
+ Preprocessing is supported by Ruby on Rails helper.
316
+ Preprocessing makes Ruby on Rails application about 20-40 percent faster.
317
+
318
+ For example,
319
+
320
+ [%= link_to 'Show', :action=>'show', :id=>_?('@user.id') %]
321
+
322
+ is evaluate by preprocessor and expanded into the following
323
+ when template file is loaded.
324
+
325
+ <a href="/users/show/<%=@user.id%>">Show</a>
326
+
327
+ It means that link_to() is not called when template is rendered
328
+ and rendering speed will be much faster in the result.
329
+
330
+ See User's Guide for details.
331
+
332
+ - |
333
+ Erubis::Eruby#evaluate() (or Erubis::RubyEvaluator#evaluate()) now
334
+ creates Proc object from @src and eval it.
335
+
336
+ def evaluate(context=Context.new)
337
+ context = Context.new(context) if context.is_a?(Hash)
338
+ @_proc ||= eval("proc { #{@src} }", TOPLEVEL_BINDING, @filename || '(erubis)')
339
+ return context.instance_eval(&@_proc)
340
+ end
341
+
342
+ This makes evaluate() much faster when eruby object is reused.
343
+
344
+ - |
345
+ Erubis::Eruby#def_method() is supported.
346
+ This method defines ruby code as instance method or singleton metod.
347
+
348
+ require 'erubis'
349
+ s = "hello <%= name %>"
350
+ eruby = Erubis::Eruby.new(s)
351
+ filename = 'hello.rhtml'
352
+
353
+ ## define instance method to Dummy class (or module)
354
+ class Dummy; end
355
+ eruby.def_method(Dummy, 'render(name)', filename) # filename is optional
356
+ p Dummy.new.render('world') #=> "hello world"
357
+
358
+ ## define singleton method to an object
359
+ obj = Object.new
360
+ eruby.def_method(obj, 'render(name)', filename) # filename is optional
361
+ p obj.render('world') #=> "hello world"
362
+
363
+ This is equivarent to ERB#def_method().
364
+
365
+ - |
366
+ Erubis::XmlHelper.url_escape() and u() which is alias of url_escape()
367
+ are added.
368
+ This is equivarent to ERB#Util.url_escape().
369
+
370
+
371
+ bugfix:
372
+ - Help message was not shown when '-h' is specified. Fixed.
373
+ - 'def method()' was not availabe in template file. Fixed.
374
+
375
+
376
+ #
377
+ - release: 2.3.1
378
+ date: 2007-05-26
379
+ bugfix:
380
+ - A serious bug in 'helpers/rails_helper.rb' is fixed.
381
+ You must be update if you are using Erubis with Ruby on Rails.
382
+
383
+
384
+ #
385
+ - release: 2.3.0
386
+ date: 2007-05-23
387
+ enhancements:
388
+ - |
389
+ New class 'Erubis::FastEruby' is added.
390
+ It is a subclass of Erubis::Eruby and includes InterpolationEnhancer.
391
+ Erubis::FastEruby is compatible with and faster than Erubis::Eruby.
392
+
393
+ - |
394
+ New enhancer 'InterpolationEnhancer' is added.
395
+ This enhancer uses expression interpolation to eliminate method call
396
+ of String#<<. In the result, this enhancer makes Eruby a little faster.
397
+
398
+ --------------------
399
+ ## Assume that input is '<a href="<%=url%>"><%=name%></a>'.
400
+ ## Eruby convert input into the following code. String#<< is called 5 times.
401
+ _buf << '<a href="'; _buf << (url).to_s; _buf << '">'; _buf << (name).to_s; _buf << '</a>';
402
+
403
+ ## When InterpolationEnhancer is used, String#<< is called only once.
404
+ _buf << %Q`<a href="#{url}">#{name}</a>`;
405
+ --------------------
406
+
407
+ - |
408
+ New enhancer 'ErboutEnhancer' is added.
409
+ ErboutEnhancer set '_erbout' as well as '_buf' to be compatible with ERB.
410
+
411
+ ex.
412
+ ====================
413
+ $ cat ex.rhtml
414
+ <p>Hello</p>
415
+ $ erubis -x ex.rhtml
416
+ _buf = ''; _buf << '<p>Hello</p>
417
+ ';
418
+ _buf.to_s
419
+ $ erubis -xE Erbout ex.rhtml
420
+ _erbout = _buf = ''; _buf << '<p>Hello</p>
421
+ ';
422
+ _buf.to_s
423
+ ====================
424
+
425
+ - |
426
+ [experimental]
427
+ New enhancer 'DeleteIndentEnhancer' is added.
428
+ This enhancer deletes indentation of HTML file.
429
+
430
+ ex.
431
+ ====================
432
+ $ cat ex.rhtml
433
+ <div>
434
+ <ul>
435
+ <% for item in ['AAA', 'BBB', 'CCC'] %>
436
+ <li><%= item %></li>
437
+ <% end %>
438
+ </ul>
439
+ </div>
440
+ $ erubis ex.rhtml
441
+ <div>
442
+ <ul>
443
+ <li>AAA</li>
444
+ <li>BBB</li>
445
+ <li>CCC</li>
446
+ </ul>
447
+ </div>
448
+ $ erubis -E DeleteIndent ex.rhtml
449
+ <div>
450
+ <ul>
451
+ <li>AAA</li>
452
+ <li>BBB</li>
453
+ <li>CCC</li>
454
+ </ul>
455
+ </div>
456
+ ====================
457
+
458
+ - |
459
+ Mod_ruby is supported (very thanks to Andrew R Jackson!).
460
+ See users-guide and 'contrib/erubis-run.rb' for details.
461
+
462
+ - |
463
+ New command-line option '-X', '-N', '-U', and '-C' are added.
464
+ These are intended to be a replacement of 'notext' command.
465
+ '-X' shows only ruby statements and expressions.
466
+ '-N' adds line numbers.
467
+ '-U' compress empty lines into a line.
468
+ '-C' removes empty lines.
469
+
470
+
471
+ changes:
472
+
473
+ - |
474
+ 'helpers/rails_helper.rb' is changed to use ErboutEnhancer.
475
+ The following is an examle to use Erubis with Ruby on Rails.
476
+
477
+ File 'config/environment.rb':
478
+ ----------------------------------------
479
+ require 'erubis/helpers/rails_helper'
480
+ #Erubis::Helpers::RailsHelper.engine_class = Erubis::Eruby # or Erubis::FastEruby
481
+ #Erubis::Helpers::RailsHelper.init_properties = {}
482
+ #Erubis::Helpers::RailsHelper.show_src = false # set true for debugging
483
+ ----------------------------------------
484
+
485
+ - |
486
+ Command 'notext' has been removed. Use '-X', '-N', '-U', and '-C'
487
+ instead.
488
+
489
+ - |
490
+ Tab characters in YAML file are expaneded automatically.
491
+ If you want not to expand tab characters, add command-line optio '-T'.
492
+
493
+ - |
494
+ Benchmark scripts (benchmark/bench.*) are rewrited.
495
+
496
+ - |
497
+ Users-guide (doc/users-guide.html) is updated.
498
+
499
+
500
+
501
+ #
502
+ - release: 2.2.0
503
+ date: 2007-02-11
504
+ enhancements:
505
+ - |
506
+ Performance tuned up. Release 2.2.0 works about 8 percent faster
507
+ than 2.1.0.
508
+ As a result, Erubis works more than 10 percent faster than eruby.
509
+ (eruby is the extension module of eRuby written in C.)
510
+
511
+ - |
512
+ Support of Ruby on Rails improved.
513
+ If you want to use Erubis with Ruby on Rails, add the following code
514
+ into your 'config/environment.rb' and restart web server.
515
+ This will set Erubis as eRuby compiler in Ruby on Rails instead of ERB.
516
+
517
+ --------------------
518
+ require 'erubis/helpers/rails_helper'
519
+ #Erubis::Helpers::RailsHelper.engine_class = Erubis::Eruby
520
+ #Erubis::Helpers::RailsHelper.init_properties = {}
521
+ #Erubis::Helpers::RailsHelper.show_src = true
522
+ --------------------
523
+
524
+ Methods 'capture()' and 'content_for()' of ActionView::Helpers::CaptureHelper
525
+ are available. Methd ActionView::Helpers::TextHelper#concat() is also available.
526
+
527
+ If Erubis::Helpers::RailsHelper.show_src is ture, Erubis prints converted
528
+ Ruby code into log file (such as 'log/development.log').
529
+
530
+ - |
531
+ Erubis::Engine.load_file(filename) creates cache file (filename +
532
+ '.cache') automatically if cache file is old or not exist.
533
+ Caching makes Erubis about 40-50 percent faster.
534
+
535
+ ex.
536
+ --------------------
537
+ require 'erubis'
538
+ eruby = Erubis::Eruby.load_file('example.rhtml')
539
+ ## cache file 'example.rhtml.cache' is created automatically
540
+ --------------------
541
+
542
+ - |
543
+ Command-line option '-f datafile' can take Ruby script ('*.rb')
544
+ as well as YAML file ('*.yaml' or '*.yml').
545
+
546
+ ex.
547
+ ====================
548
+ $ cat context.rb
549
+ @title = 'Example'
550
+ @list = %w[AAA BBB CCC]
551
+ $ cat example.rhtml
552
+ <h1><%= @title %></h1>
553
+ <ul>
554
+ <% for item in @list %>
555
+ <li><%= item %></li>
556
+ <% end %>
557
+ </ul>
558
+ $ erubis -f context.rb example.rhtml
559
+ <h1>Example</h1>
560
+ <ul>
561
+ <li>AAA</li>
562
+ <li>BBB</li>
563
+ <li>CCC</li>
564
+ </ul>
565
+ ====================
566
+
567
+ - |
568
+ New command-line option '-c context' support. It takes context string
569
+ in YAML inline style or Ruby code style.
570
+
571
+ ex. YAML inline style
572
+ ====================
573
+ $ erubis -c '{title: Example, list: [AAA, BBB, CCC]}' example.rhtml
574
+ ====================
575
+
576
+ ex. Ruby style
577
+ ====================
578
+ $ erubis -c '@title="Example"; @list=%w[AAA BBB CCC]' example.rhtml
579
+ ====================
580
+
581
+ - |
582
+ New command-line option '-z' (syntax checking) support. It is similar
583
+ to 'erubis -x file.rhtml | ruby -wc', but it can take several filenames.
584
+
585
+ ex.
586
+ ====================
587
+ $ erubis -z app/views/*/*.rhtml
588
+ Syntax OK
589
+ ====================
590
+
591
+ - |
592
+ New constant Erubis::VERSION added.
593
+
594
+
595
+ changes:
596
+ - |
597
+ Class Erubis::Eruby changed to include Erubis::StringBufferEnhancer
598
+ instead of Erubis::ArrayBufferEnhancer.
599
+ This is for Ruby on Rails support.
600
+
601
+ ex.
602
+ ====================
603
+ $ cat example.rhtml
604
+ <ul>
605
+ <% for item in @list %>
606
+ <li><%= item %></li>
607
+ <% end %>
608
+ </ul>
609
+ $ erubis -x example.rhtml
610
+ _buf = ''; _buf << '<ul>
611
+ '; for item in @list
612
+ _buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
613
+ '; end
614
+ _buf << '</ul>
615
+ ';
616
+ _buf.to_s
617
+ ====================
618
+
619
+ - |
620
+ Erubis::StringBufferEnhancer#add_postamble() prints "_buf.to_s"
621
+ instead of "_buf".
622
+ This is useful for 'erubis -x file.rhtml | ruby -wc'.
623
+
624
+ - |
625
+ Command-line option '-T' is removed. Use '--trim=false' instead.
626
+
627
+ - |
628
+ License is changed to MIT License.
629
+
630
+ - |
631
+ Embedded pattern '<%- -%>' can be handled.
632
+
633
+
634
+ #
635
+ - release: 2.1.0
636
+ date: 2006-09-23
637
+ enhancements:
638
+ - |
639
+ Ruby on Rails support. Add the following code to
640
+ your 'app/controllers/application.rb' and restart web server.
641
+
642
+ --------------------
643
+ require 'erubis/helper/rails'
644
+ suffix = 'erubis'
645
+ ActionView::Base.register_template_handler(suffix, Erubis::Helper::RailsTemplate)
646
+ #Erubis::Helper::RailsTemplate.engine_class = Erubis::EscapedEruby ## or Erubis::PI::Eruby
647
+ #Erubis::Helper::RailsTemplate.default_properties = { :escape=>true, :escapefunc=>'h' }
648
+ --------------------
649
+
650
+ And rename your view template as 'xxx.erubis'.
651
+ If you got the "(eval):10:in `render': no block given" error,
652
+ use '@content_for_layout' instead 'yield' in your layout template.
653
+
654
+ - |
655
+ Another eRuby engine (PIEngine) support. This engine doesn't
656
+ break HTML design because it uses Processing Instructions (PI)
657
+ '<?rb .. ?>' as embedded pattern instead of '<% .. %>'.
658
+
659
+ example.rhtml
660
+ --------------------
661
+ <table>
662
+ <?rb @list.each_with_index do |item, i| ?>
663
+ <?rb klass = i % 2 == 0 ? 'odd' : 'even' ?>
664
+ <tr class="@{klass}@">
665
+ <td>@!{item}@</td>
666
+ </tr>
667
+ <?rb end ?>
668
+ </table>
669
+ --------------------
670
+
671
+ compile:
672
+ ====================
673
+ $ erubis -x --pi example.rhtml
674
+ _buf = []; _buf << '<table>
675
+ '; @list.each_with_index do |item, i|
676
+ klass = i % 2 == 0 ? 'odd' : 'even'
677
+ _buf << ' <tr class="'; _buf << Erubis::XmlHelper.escape_xml(klass); _buf << '">
678
+ <td>'; _buf << (item).to_s; _buf << '</td>
679
+ </tr>
680
+ '; end
681
+ _buf << '</table>
682
+ ';
683
+ _buf.join
684
+ ====================
685
+
686
+ - |
687
+ Add new command 'notext' which remove text part from eRuby
688
+ script and leaves only Ruby code.
689
+ This is very useful for debug of eRuby script.
690
+
691
+ example2.rhtml
692
+ --------------------
693
+ <html>
694
+ <body>
695
+ <table>
696
+ <% @list.each_with_index do |item, i| %>
697
+ <% klass = i % 2 == 0 ? 'odd' : 'even' %>
698
+ <tr class="<%= klass %>">
699
+ <td><%== item %></td>
700
+ </tr>
701
+ <% end %>
702
+ </table>
703
+ </body>
704
+ </html>
705
+ --------------------
706
+
707
+ command line example:
708
+ ====================
709
+ $ notext example2.rhtml
710
+ _buf = [];
711
+
712
+
713
+ @list.each_with_index do |item, i| ;
714
+ klass = i % 2 == 0 ? 'odd' : 'even' ;
715
+ _buf << ( klass ).to_s;
716
+ _buf << Erubis::XmlHelper.escape_xml( item );
717
+
718
+ end ;
719
+
720
+
721
+
722
+ _buf.join
723
+ $ notext -nc example2.rhtml
724
+ 1: _buf = [];
725
+ 4: @list.each_with_index do |item, i| ;
726
+ 5: klass = i % 2 == 0 ? 'odd' : 'even' ;
727
+ 6: _buf << ( klass ).to_s;
728
+ 7: _buf << Erubis::XmlHelper.escape_xml( item );
729
+ 9: end ;
730
+ 13: _buf.join
731
+ ====================
732
+
733
+ - |
734
+ Add new enhance 'NoCode' which removes ruby code from
735
+ eRuby script and leaves only HTML text part.
736
+ It is very useful to validate HTML of eRuby script.
737
+
738
+ command-line example:
739
+ ====================
740
+ $ erubis -x -E NoCode example2.rhtml
741
+ <html>
742
+ <body>
743
+ <table>
744
+
745
+
746
+ <tr class="">
747
+ <td></td>
748
+ </tr>
749
+
750
+ </table>
751
+ </body>
752
+ </html>
753
+ ====================
754
+
755
+ changes:
756
+ - License is changed to LGPL.
757
+ - Command-line property '--escape=name' is renamed to
758
+ '--escapefunc=name'.
759
+ - When command-line option '-l perl' is specified, function
760
+ 'encode_entities()' is used ad escaping function which is
761
+ available wth HTML::Entities module.
762
+
763
+ bugfix:
764
+ - There is a certain pattern which makes Engine#convert()
765
+ too slow. Now Engne#convert() is fixed not to be slown.
766
+ - Command name is now displayed when '-h' is specified.
767
+
768
+
769
+ #
770
+ - release: 2.0.1
771
+ date: 2006-06-21
772
+ bugfix:
773
+ - some minor bugs are fixed
774
+
775
+
776
+ #
777
+ - release: 2.0.0
778
+ date: 2006-05-20
779
+ changes:
780
+ - module 'PrintEnhancer' is renamed to 'PrintEnabledEnahncer'
781
+ - module 'FastEnhancer' and class 'FastEruby' is obsolete because they are integrated into Eruby class
782
+ - Eruby#evaluate() calls instance_eval() instead of eval()
783
+ - XmlEruby.escape_xml() is moved to XmlHelper.escape_xml()
784
+ enhancements:
785
+ - multi programming language support (Ruby/PHP/C/Java/Scheme/Perl/Javascript)
786
+ - class Eruby runs very fast because FastEnhancer module is integrated into Eruby by default
787
+ - TinyEruby class (tiny.rb) is added
788
+ - module ArrayBufferEnhancer added
789
+ - module ArrayEnhancer added
790
+ - module BiPatternEnhancer added
791
+ - module EscapeEnhancer added
792
+ - module HeaderFooterEnhancer added
793
+ - module NoTextEnhancer added
794
+ - module PercentLineEnhancer added
795
+ - module PrintEnabledEnhancer added
796
+ - module PrintOutEnhancer added
797
+ - module SimplifyEnhancer added
798
+ - module StringBufferEnhancer added
799
+ - module StringIOEnhancer added
800
+ - command-line option '-b' (body only) added
801
+ - command-line option '-e' (escape) added
802
+ - command-line option '-l' (lang) added
803
+ - command-line option '-E' (enhancer) added
804
+ - command-line option '-I' (require path) added
805
+ - command-line option '-K' (kanji code) added
806
+ - command-line option '-S' (string to symbol) added
807
+ - command-line option '-B' (call result(binding())) added
808
+
809
+
810
+ #
811
+ - release: 1.1.0
812
+ date: 2006-03-05
813
+ enhancements:
814
+ - '<%# ... %>' is supported
815
+ - PrintEnhancer, PrintEruby, and PrintXmlEruby added
816
+
817
+ - release: 1.0.1
818
+ date: 2006-02-01
819
+ bugfixes:
820
+ - bin/erubis is available with RubyGems
821
+
822
+
823
+ #
824
+ - release: 1.0.0
825
+ date: 2006-02-01
826
+ bugfixes:
827
+ - first release
828
+