Class: ERB
- Inherits:
-
Object
- Object
- ERB
- Defined in:
- lib/erbpp/line_number.rb
Instance Method Summary collapse
- #result(b = new_toplevel) ⇒ Object
- #result_orig ⇒ Object
- #src ⇒ Object
- #src_orig ⇒ Object
- #src_with_cpp_line ⇒ Object
Instance Method Details
#result(b = new_toplevel) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/erbpp/line_number.rb', line 91 def result(b=new_toplevel) src = src_with_cpp_line if @safe_level proc { $SAFE = @safe_level eval(src, b, (@filename || '(erb)'), 0) }.call else #open("tmpout","w"){|f| f.write src} if /dtype/=~@filename eval(src, b, (@filename || '(erb)'), 0) end end |
#result_orig ⇒ Object
89 |
# File 'lib/erbpp/line_number.rb', line 89 alias result_orig result |
#src ⇒ Object
106 107 108 |
# File 'lib/erbpp/line_number.rb', line 106 def src src_with_cpp_line end |
#src_orig ⇒ Object
104 |
# File 'lib/erbpp/line_number.rb', line 104 alias src_orig src |
#src_with_cpp_line ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/erbpp/line_number.rb', line 110 def src_with_cpp_line @src.each_line.with_index.map do |line, num| line.gsub!(/_erbout.concat "/,'_erbout.concat0 "') line.gsub!(/_erbout.concat\(/,'_erbout.concat1(') if num==0 # skip elsif num==1 f = @filename.dump line.sub!(/_erbout = (''|String\.new);/, "_erbout = CountLnString.new(#{f});") elsif /^; _erbout\.force_encoding/ =~ line line.sub!(/^;/,";_erbout.ln(#{num});") end line end.join end |