erubis 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. data/{ChangeLog → CHANGES} +139 -6
  2. data/MIT-LICENSE +20 -0
  3. data/README.txt +20 -5
  4. data/benchmark/erubybench.rb +465 -229
  5. data/benchmark/erubybench.rhtml +39 -15
  6. data/benchmark/erubybench.yaml +126 -46
  7. data/bin/erubis +2 -2
  8. data/bin/notext +3 -3
  9. data/contrib/action_view_base_rb.patch +23 -0
  10. data/contrib/erubis +466 -308
  11. data/contrib/inline-require +2 -2
  12. data/doc-api/classes/ERB.html +101 -0
  13. data/doc-api/classes/Erubis.html +59 -6
  14. data/doc-api/classes/Erubis/ArrayEnhancer.html +12 -12
  15. data/doc-api/classes/Erubis/Basic/Converter.html +61 -57
  16. data/doc-api/classes/Erubis/BiPatternEnhancer.html +14 -14
  17. data/doc-api/classes/Erubis/CGenerator.html +60 -60
  18. data/doc-api/classes/Erubis/Context.html +125 -29
  19. data/doc-api/classes/Erubis/Converter.html +73 -22
  20. data/doc-api/classes/Erubis/Engine.html +55 -39
  21. data/doc-api/classes/Erubis/EscapeEnhancer.html +6 -6
  22. data/doc-api/classes/Erubis/Evaluator.html +19 -19
  23. data/doc-api/classes/Erubis/Generator.html +16 -10
  24. data/doc-api/classes/Erubis/HeaderFooterEnhancer.html +14 -14
  25. data/doc-api/classes/Erubis/{Helper.html → Helpers.html} +5 -6
  26. data/doc-api/classes/Erubis/Helpers/RailsHelper.html +296 -0
  27. data/doc-api/classes/Erubis/JavaGenerator.html +54 -54
  28. data/doc-api/classes/Erubis/JavascriptGenerator.html +60 -60
  29. data/doc-api/classes/Erubis/Main.html +42 -30
  30. data/doc-api/classes/Erubis/NoCodeEnhancer.html +5 -5
  31. data/doc-api/classes/Erubis/NoTextEnhancer.html +7 -7
  32. data/doc-api/classes/Erubis/OptimizedEruby.html +6 -6
  33. data/doc-api/classes/Erubis/OptimizedGenerator.html +72 -72
  34. data/doc-api/classes/Erubis/OptimizedXmlEruby.html +6 -6
  35. data/doc-api/classes/Erubis/PI/Converter.html +28 -81
  36. data/doc-api/classes/Erubis/PI/Ec.html +6 -6
  37. data/doc-api/classes/Erubis/PI/Ejava.html +6 -6
  38. data/doc-api/classes/Erubis/PI/Ejavascript.html +6 -6
  39. data/doc-api/classes/Erubis/PI/Eperl.html +6 -6
  40. data/doc-api/classes/Erubis/PI/Ephp.html +6 -6
  41. data/doc-api/classes/Erubis/PI/Eruby.html +7 -7
  42. data/doc-api/classes/Erubis/PI/Escheme.html +6 -6
  43. data/doc-api/classes/Erubis/PI/TinyEruby.html +66 -79
  44. data/doc-api/classes/Erubis/PercentLineEnhancer.html +8 -8
  45. data/doc-api/classes/Erubis/PerlGenerator.html +54 -54
  46. data/doc-api/classes/Erubis/PhpGenerator.html +54 -54
  47. data/doc-api/classes/Erubis/PrintEnabledEnhancer.html +21 -21
  48. data/doc-api/classes/Erubis/PrintOutEnhancer.html +30 -30
  49. data/doc-api/classes/Erubis/RubyEvaluator.html +12 -12
  50. data/doc-api/classes/Erubis/RubyGenerator.html +9 -9
  51. data/doc-api/classes/Erubis/SimplifyEnhancer.html +7 -6
  52. data/doc-api/classes/Erubis/StdoutEnhancer.html +12 -12
  53. data/doc-api/classes/Erubis/StringBufferEnhancer.html +13 -13
  54. data/doc-api/classes/Erubis/TinyEruby.html +56 -68
  55. data/doc-api/classes/Erubis/XmlHelper.html +20 -23
  56. data/doc-api/created.rid +1 -1
  57. data/doc-api/files/{__/README_txt.html → README_txt.html} +35 -20
  58. data/doc-api/files/erubis/context_rb.html +2 -2
  59. data/doc-api/files/erubis/converter_rb.html +2 -2
  60. data/doc-api/files/erubis/engine/ec_rb.html +2 -2
  61. data/doc-api/files/erubis/engine/ejava_rb.html +2 -2
  62. data/doc-api/files/erubis/engine/ejavascript_rb.html +2 -2
  63. data/doc-api/files/erubis/engine/enhanced_rb.html +2 -2
  64. data/doc-api/files/erubis/engine/eperl_rb.html +2 -2
  65. data/doc-api/files/erubis/engine/ephp_rb.html +2 -2
  66. data/doc-api/files/erubis/engine/eruby_rb.html +2 -3
  67. data/doc-api/files/erubis/engine/escheme_rb.html +2 -2
  68. data/doc-api/files/erubis/engine/optimized_rb.html +2 -2
  69. data/doc-api/files/erubis/engine_rb.html +2 -2
  70. data/doc-api/files/erubis/enhancer_rb.html +2 -2
  71. data/doc-api/files/erubis/error_rb.html +2 -2
  72. data/doc-api/files/erubis/evaluator_rb.html +2 -2
  73. data/doc-api/files/erubis/generator_rb.html +2 -2
  74. data/doc-api/files/erubis/helper_rb.html +2 -2
  75. data/doc-api/files/erubis/{helper/rails_rb.html → helpers/rails_helper_rb.html} +6 -31
  76. data/doc-api/files/erubis/local-setting_rb.html +2 -2
  77. data/doc-api/files/erubis/main_rb.html +4 -2
  78. data/doc-api/files/erubis/tiny_rb.html +2 -2
  79. data/doc-api/files/erubis_rb.html +2 -2
  80. data/doc-api/fr_class_index.html +3 -3
  81. data/doc-api/fr_file_index.html +2 -2
  82. data/doc-api/fr_method_index.html +142 -147
  83. data/doc-api/index.html +1 -1
  84. data/doc/users-guide.html +387 -218
  85. data/lib/erubis.rb +21 -25
  86. data/lib/erubis/context.rb +34 -4
  87. data/lib/erubis/converter.rb +159 -115
  88. data/lib/erubis/engine.rb +29 -12
  89. data/lib/erubis/engine/ec.rb +2 -2
  90. data/lib/erubis/engine/ejava.rb +2 -2
  91. data/lib/erubis/engine/ejavascript.rb +2 -2
  92. data/lib/erubis/engine/enhanced.rb +2 -2
  93. data/lib/erubis/engine/eperl.rb +2 -2
  94. data/lib/erubis/engine/ephp.rb +2 -2
  95. data/lib/erubis/engine/eruby.rb +5 -6
  96. data/lib/erubis/engine/escheme.rb +2 -2
  97. data/lib/erubis/engine/optimized.rb +2 -2
  98. data/lib/erubis/enhancer.rb +33 -7
  99. data/lib/erubis/error.rb +2 -2
  100. data/lib/erubis/evaluator.rb +2 -2
  101. data/lib/erubis/generator.rb +6 -3
  102. data/lib/erubis/helper.rb +6 -23
  103. data/lib/erubis/helpers/rails_helper.rb +202 -0
  104. data/lib/erubis/local-setting.rb +4 -4
  105. data/lib/erubis/main.rb +90 -35
  106. data/lib/erubis/tiny.rb +57 -52
  107. data/test/assert-text-equal.rb +2 -2
  108. data/test/test-engines.rb +5 -5
  109. data/test/test-erubis.rb +173 -63
  110. data/test/test-main.rb +135 -27
  111. data/test/test-notext.rb +2 -2
  112. data/test/test.rb +2 -2
  113. data/test/testutil.rb +2 -2
  114. metadata +16 -16
  115. data/LGPL +0 -504
  116. data/doc-api/classes/Erubis/Helper/CachedRailsTemplate.html +0 -198
  117. data/doc-api/classes/Erubis/Helper/RailsTemplate.html +0 -366
  118. data/lib/erubis/helper/rails.rb +0 -159
@@ -1,10 +1,10 @@
1
1
  ##
2
- ## $Rev: 13 $
3
- ## $Release: 2.1.0 $
4
- ## copyright(c) 2006 kuwata-lab all rights reserved.
2
+ ## $Rev: 42 $
3
+ ## $Release: 2.2.0 $
4
+ ## copyright(c) 2006-2007 kuwata-lab all rights reserved.
5
5
  ##
6
6
 
7
7
  ##
8
8
  ## you can add site-local settings here.
9
- ## this files is 'require'd by erubis.rb
9
+ ## this files is required by erubis.rb
10
10
  ##
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 41 $
3
- ### $Release: 2.1.0 $
4
- ### copyright(c) 2006 kuwata-lab all rights reserved.
2
+ ### $Rev: 65 $
3
+ ### $Release: 2.2.0 $
4
+ ### copyright(c) 2006-2007 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  require 'yaml'
@@ -49,22 +49,24 @@ module Erubis
49
49
  end
50
50
 
51
51
  def initialize
52
- @single_options = "hvxTtSbeB"
53
- @arg_options = "pcrfKIlaE"
52
+ @single_options = "hvxztSbeB"
53
+ @arg_options = "pcrfKIlaEC"
54
54
  @option_names = {
55
55
  ?h => :help,
56
56
  ?v => :version,
57
57
  ?x => :source,
58
- ?T => :notrim,
58
+ ?z => :syntax,
59
+ #?T => :notrim,
59
60
  ?t => :untabify,
60
61
  ?S => :intern,
61
62
  ?b => :bodyonly,
62
63
  ?B => :binding,
63
64
  ?p => :pattern,
64
- ?c => :class,
65
+ ?c => :context,
66
+ ?C => :class,
65
67
  ?e => :escape,
66
68
  ?r => :requires,
67
- ?f => :yamlfiles,
69
+ ?f => :datafiles,
68
70
  ?K => :kanji,
69
71
  ?I => :includes,
70
72
  ?l => :lang,
@@ -112,6 +114,7 @@ module Erubis
112
114
 
113
115
  ## action
114
116
  action = opts.action
117
+ action ||= 'syntax' if opts.syntax
115
118
  action ||= 'convert' if opts.source
116
119
 
117
120
  ## lang
@@ -126,13 +129,18 @@ module Erubis
126
129
  $KCODE = opts.kanji if opts.kanji
127
130
 
128
131
  ## read context values from yaml file
129
- yamlfiles = opts.yamlfiles
130
- context = load_yamlfiles(yamlfiles, opts)
132
+ datafiles = opts.datafiles
133
+ context = load_datafiles(datafiles, opts)
134
+
135
+ ## parse context data
136
+ if opts.context
137
+ context = parse_context_data(opts.context, opts)
138
+ end
131
139
 
132
140
  ## properties for engine
133
141
  properties[:escape] = true if opts.escape && !properties.key?(:escape)
134
142
  properties[:pattern] = opts.pattern if opts.pattern
135
- properties[:trim] = false if opts.notrim
143
+ #properties[:trim] = false if opts.notrim
136
144
  properties[:preamble] = properties[:postamble] = false if opts.bodyonly
137
145
  properties[:pi] = nil if properties[:pi] == true
138
146
 
@@ -147,32 +155,39 @@ module Erubis
147
155
 
148
156
  ## convert and execute
149
157
  val = nil
158
+ msg = "Syntax OK\n"
150
159
  if filenames && !filenames.empty?
151
160
  filenames.each do |filename|
152
161
  test(?f, filename) or raise CommandOptionError.new("#{filename}: file not found.")
153
162
  engine.filename = filename
154
163
  engine.convert!(File.read(filename))
155
- print val if val = do_action(action, engine, context, opts)
164
+ val = do_action(action, engine, context, filename, opts)
165
+ msg = nil if val
156
166
  end
157
167
  else
158
168
  engine.filename = '(stdin)'
159
169
  engine.convert!($stdin.read())
160
- print val if val = do_action(action, engine, context, opts)
170
+ val = do_action(action, engine, context, filename, opts)
171
+ msg = nil if val
161
172
  end
173
+ print msg if action == 'syntax' && msg
162
174
 
163
175
  end
164
176
 
165
177
  private
166
178
 
167
- def do_action(action, engine, context, opts)
179
+ def do_action(action, engine, context, filename, opts)
168
180
  case action
169
181
  when 'convert'
170
182
  s = engine.src
171
183
  when nil, 'exec', 'execute'
172
- s = opts.binding ? engine.result(context) : engine.evaluate(context)
184
+ s = opts.binding ? engine.result(context.to_hash) : engine.evaluate(context)
185
+ when 'syntax'
186
+ s = check_syntax(filename, engine.src)
173
187
  else
174
188
  raise "*** internal error"
175
189
  end
190
+ print s if s
176
191
  return s
177
192
  end
178
193
 
@@ -183,8 +198,8 @@ erubis - embedded program converter for multi-language
183
198
  Usage: #{command} [..options..] [file ...]
184
199
  -h, --help : help
185
200
  -v : version
186
- -x : converted code
187
- -T : don't trim spaces around '<% %>'
201
+ -x : show converted code
202
+ -z : syntax checking
188
203
  -b : body only (no preamble nor postamble)
189
204
  -e : escape (equal to '--E Escape')
190
205
  -p pattern : embedded pattern (default '<% %>')
@@ -192,7 +207,8 @@ Usage: #{command} [..options..] [file ...]
192
207
  -E e1,e2,... : enhancer names (Escape, PercentLine, BiPattern, ...)
193
208
  -I path : library include path
194
209
  -K kanji : kanji code (euc/sjis/utf8) (default none)
195
- -f file.yaml : YAML file for context values (read stdin if filename is '-')
210
+ -c context : context data string (yaml inline style or ruby code)
211
+ -f datafile : context data file ('*.yaml', '*.yml', or '*.rb')
196
212
  -t : expand tab character in YAML file
197
213
  -S : convert mapping key from string to symbol in YAML file
198
214
  -B : invoke 'result(binding)' instead of 'evaluate(context)'
@@ -200,6 +216,7 @@ Usage: #{command} [..options..] [file ...]
200
216
 
201
217
  END
202
218
  #'
219
+ # -T : don't trim spaces around '<% %>'
203
220
  # -c class : class name (XmlEruby/PercentLineEruby/...) (default Eruby)
204
221
  # -r library : require library
205
222
  # -a : action (convert/execute)
@@ -254,8 +271,7 @@ END
254
271
  end
255
272
 
256
273
  def version
257
- release = ('$Release: 2.1.0 $' =~ /([.\d]+)/) && $1
258
- return release
274
+ return Erubis::VERSION
259
275
  end
260
276
 
261
277
  def parse_argv(argv, arg_none='', arg_required='', arg_optional='')
@@ -362,27 +378,51 @@ END
362
378
  return enhancers
363
379
  end
364
380
 
365
- def load_yamlfiles(yamlfiles, opts)
366
- hash = {}
367
- return hash unless yamlfiles
368
- yamlfiles.split(/,/).each do |yamlfile|
369
- if yamlfile == '-'
370
- str = $stdin.read()
381
+ def load_datafiles(filenames, opts)
382
+ context = Erubis::Context.new
383
+ return hash unless filenames
384
+ filenames.split(/,/).each do |filename|
385
+ filename.strip!
386
+ test(?f, filename) or raise CommandOptionError.new("#{filename}: file not found.")
387
+ if filename =~ /\.ya?ml$/
388
+ if opts.untabify
389
+ ydoc = YAML.load(untabify(File.read(filename)))
390
+ else
391
+ ydoc = YAML.load_file(filename)
392
+ end
393
+ ydoc.is_a?(Hash) or raise CommandOptionError.new("#{filename}: root object is not a mapping.")
394
+ intern_hash_keys(ydoc) if opts.intern
395
+ context.update(ydoc)
396
+ elsif filename =~ /\.rb$/
397
+ str = File.read(filename)
398
+ context2 = Erubis::Context.new
399
+ _instance_eval(context2, str)
400
+ context.update(context2)
371
401
  else
372
- test(?f, yamlfile) or raise CommandOptionError.new("#{yamlfile}: file not found.")
373
- str = File.read(yamlfile)
402
+ CommandOptionError.new("#{filename}: '*.yaml', '*.yml', or '*.rb' required.")
374
403
  end
375
- str = yamlfile == '-' ? $stdin.read() : File.read(yamlfile)
376
- str = untabify(str) if opts.untabify
377
- ydoc = YAML.load(str)
404
+ end
405
+ return context
406
+ end
407
+
408
+ def _instance_eval(_context, _str)
409
+ _context.instance_eval(_str)
410
+ end
411
+
412
+ def parse_context_data(context_str, opts)
413
+ if context_str[0] == ?{
414
+ require 'yaml'
415
+ ydoc = YAML.load(context_str)
378
416
  unless ydoc.is_a?(Hash)
379
- raise CommandOptionError.new("#{yamlfile}: root object is not a mapping.")
417
+ raise CommandOptionError.new("-c: root object is not a mapping.")
380
418
  end
381
419
  intern_hash_keys(ydoc) if opts.intern
382
- hash.update(ydoc)
420
+ return ydoc
421
+ else
422
+ context = Erubis::Context.new
423
+ context.instance_eval(context_str, '-c')
424
+ return context
383
425
  end
384
- context = hash
385
- return context
386
426
  end
387
427
 
388
428
  def intern_hash_keys(obj, done={})
@@ -404,6 +444,21 @@ END
404
444
  end
405
445
  end
406
446
 
447
+ def check_syntax(filename, src)
448
+ require 'open3'
449
+ stdin, stdout, stderr = Open3.popen3('ruby -wc')
450
+ stdin.write(src)
451
+ stdin.close
452
+ result = stdout.read()
453
+ stdout.close()
454
+ errmsg = stderr.read()
455
+ stderr.close()
456
+ return nil unless errmsg && !errmsg.empty?
457
+ errmsg =~ /\A-:(\d+): /
458
+ linenum, message = $1, $'
459
+ return "#{filename}:#{linenum}: #{message}"
460
+ end
461
+
407
462
  end
408
463
 
409
464
  end
@@ -1,7 +1,7 @@
1
1
  ##
2
- ## $Rev: 35 $
3
- ## $Release: 2.1.0 $
4
- ## copyright(c) 2006 kuwata-lab all rights reserved.
2
+ ## $Rev: 54 $
3
+ ## $Release: 2.2.0 $
4
+ ## copyright(c) 2006-2007 kuwata-lab all rights reserved.
5
5
  ##
6
6
 
7
7
  module Erubis
@@ -25,44 +25,47 @@ module Erubis
25
25
  EMBEDDED_PATTERN = /<%(=+|\#)?(.*?)-?%>/m
26
26
 
27
27
  def convert(input)
28
- src = "_buf = [];" # preamble
28
+ src = "_buf = '';" # preamble
29
29
  pos = 0
30
30
  input.scan(EMBEDDED_PATTERN) do |indicator, code|
31
31
  match = Regexp.last_match
32
- index = match.begin(0)
33
- text = input[pos, index - pos]
32
+ len = match.begin(0) - pos
33
+ text = input[pos, len]
34
34
  pos = match.end(0)
35
- src << " _buf << '" << escape_text(text) << "';"
35
+ #src << " _buf << '" << escape_text(text) << "';"
36
+ text.gsub!(/['\\]/, '\\\\\&')
37
+ src << " _buf << '" << text << "';" unless text.empty?
36
38
  if !indicator # <% %>
37
39
  src << code << ";"
38
- elsif indicator[0] == ?\# # <%# %>
39
- n = code.count("\n")
40
- add_stmt(src, "\n" * n)
40
+ elsif indicator == '#' # <%# %>
41
+ src << ("\n" * code.count("\n"))
41
42
  else # <%= %>
42
43
  src << " _buf << (" << code << ").to_s;"
43
44
  end
44
45
  end
45
46
  rest = $' || input
46
- src << " _buf << '" << escape_text(rest) << "';"
47
- src << "\n_buf.join\n" # postamble
47
+ #src << " _buf << '" << escape_text(rest) << "';"
48
+ rest.gsub!(/['\\]/, '\\\\\&')
49
+ src << " _buf << '" << rest << "';" unless rest.empty?
50
+ src << "\n_buf.to_s\n" # postamble
48
51
  return src
49
52
  end
50
53
 
51
- def escape_text(text)
52
- return text.gsub!(/['\\]/, '\\\\\&') || text
53
- end
54
+ #def escape_text(text)
55
+ # return text.gsub!(/['\\]/, '\\\\\&') || text
56
+ #end
54
57
 
55
- def result(binding=TOPLEVEL_BINDING)
56
- eval @src, binding
58
+ def result(_binding=TOPLEVEL_BINDING)
59
+ eval @src, _binding
57
60
  end
58
61
 
59
- def evaluate(context=Object.new)
60
- if context.is_a?(Hash)
61
- obj = Object.new
62
- context.each do |k, v| obj.instance_variable_set("@#{k}", v) end
63
- context = obj
62
+ def evaluate(_context=Object.new)
63
+ if _context.is_a?(Hash)
64
+ _obj = Object.new
65
+ _context.each do |k, v| _obj.instance_variable_set("@#{k}", v) end
66
+ _context = _obj
64
67
  end
65
- context.instance_eval @src
68
+ _context.instance_eval @src
66
69
  end
67
70
 
68
71
  end
@@ -81,56 +84,58 @@ module Erubis
81
84
 
82
85
  attr_reader :src
83
86
 
84
- EMBEDDED_PATTERN = /(^[ \t]*)?<\?rb(\s.*?)\?>([ \t]*\r?\n)?|\$(!*)?\{(.*?)\}/
87
+ EMBEDDED_PATTERN = /(^[ \t]*)?<\?rb(\s.*?)\?>([ \t]*\r?\n)?|@(!+)?\{(.*?)\}@/m
85
88
 
86
89
  def convert(input)
87
- src = "_buf = [];" # preamble
90
+ src = "_buf = '';" # preamble
88
91
  pos = 0
89
- input.scan(EMBEDDED_PATTERN) do |lspace, stmtcode, rspace, indicator, exprcode|
92
+ input.scan(EMBEDDED_PATTERN) do |lspace, stmt, rspace, indicator, expr|
90
93
  match = Regexp.last_match
91
- index = match.begin(0)
92
- text = input[pos, index - pos]
94
+ len = match.begin(0) - pos
95
+ text = input[pos, len]
93
96
  pos = match.end(0)
94
- if stmtcode # <?rb ... ?>
95
- code = stmtcode
96
- src << " _buf << '" << escape_text(text) << "';"
97
+ #src << " _buf << '" << escape_text(text) << "';"
98
+ text.gsub!(/['\\]/, '\\\\\&')
99
+ src << " _buf << '" << text << "';" unless text.empty?
100
+ if stmt # <?rb ... ?>
97
101
  if lspace && rspace
98
- src << "#{lspace}#{code}#{rspace}"
102
+ src << "#{lspace}#{stmt}#{rspace}"
99
103
  else
100
- src << " _buf << '#{lspace}';" if lspace
101
- src << code << ";"
102
- src << " _buf << '#{rspace}';" if rspace
104
+ src << " _buf << '" << lspace << "';" if lspace
105
+ src << stmt << ";"
106
+ src << " _buf << '" << rspace << "';" if rspace
103
107
  end
104
108
  else # ${...}, $!{...}
105
- code = exprcode
106
- if indicator.nil? || indicator.empty?
107
- src << " _buf << #{@escape}(" << code << ");"
109
+ if !indicator
110
+ src << " _buf << " << @escape << "(" << expr << ");"
108
111
  elsif indicator == '!'
109
- src << " _buf << (" << code << ").to_s;"
112
+ src << " _buf << (" << expr << ").to_s;"
110
113
  end
111
114
  end
112
115
  end
113
116
  rest = $' || input
114
- src << " _buf << '" << escape_text(rest) << "';"
115
- src << "\n_buf.join\n" # postamble
117
+ #src << " _buf << '" << escape_text(rest) << "';"
118
+ rest.gsub!(/['\\]/, '\\\\\&')
119
+ src << " _buf << '" << rest << "';" unless rest.empty?
120
+ src << "\n_buf.to_s\n" # postamble
116
121
  return src
117
122
  end
118
123
 
119
- def escape_text(text)
120
- return text.gsub!(/['\\]/, '\\\\\&') || text
121
- end
124
+ #def escape_text(text)
125
+ # return text.gsub!(/['\\]/, '\\\\\&') || text
126
+ #end
122
127
 
123
- def result(binding=TOPLEVEL_BINDING)
124
- eval @src, binding
128
+ def result(_binding=TOPLEVEL_BINDING)
129
+ eval @src, _binding
125
130
  end
126
131
 
127
- def evaluate(context=Object.new)
128
- if context.is_a?(Hash)
129
- obj = Object.new
130
- context.each do |k, v| obj.instance_variable_set("@#{k}", v) end
131
- context = obj
132
+ def evaluate(_context=Object.new)
133
+ if _context.is_a?(Hash)
134
+ _obj = Object.new
135
+ _context.each do |k, v| _obj.instance_variable_set("@#{k}", v) end
136
+ _context = _obj
132
137
  end
133
- context.instance_eval @src
138
+ _context.instance_eval @src
134
139
  end
135
140
 
136
141
  end
@@ -1,7 +1,7 @@
1
1
  ###
2
2
  ### $Rev: 6 $
3
- ### $Release: 2.1.0 $
4
- ### copyright(c) 2006 kuwata-lab all rights reserved.
3
+ ### $Release: 2.2.0 $
4
+ ### copyright(c) 2006-2007 kuwata-lab all rights reserved.
5
5
  ###
6
6
 
7
7
  require 'test/unit'
@@ -1,7 +1,7 @@
1
1
  ##
2
- ## $Rev: 40 $
3
- ## $Release: 2.1.0 $
4
- ## copyright(c) 2006 kuwata-lab all rights reserved.
2
+ ## $Rev: 54 $
3
+ ## $Release: 2.2.0 $
4
+ ## copyright(c) 2006-2007 kuwata-lab all rights reserved.
5
5
  ##
6
6
 
7
7
  require "#{File.dirname(__FILE__)}/test.rb"
@@ -50,7 +50,7 @@ __END__
50
50
  </table>
51
51
  <%=== i+1 %>
52
52
  expected: |
53
- _buf = []; _buf << '<table>
53
+ _buf = ''; _buf << '<table>
54
54
  <tbody>
55
55
  '; i = 0
56
56
  list.each_with_index do |item, i|
@@ -63,7 +63,7 @@ __END__
63
63
  </table>
64
64
  '; $stderr.puts("*** debug: i+1=#{(i+1).inspect}"); _buf << '
65
65
  ';
66
- _buf.join
66
+ _buf.to_s
67
67
  ##
68
68
  - name: php1
69
69
  lang: php