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
98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/erbpp/line_number.rb', line 98 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
96 |
# File 'lib/erbpp/line_number.rb', line 96 alias result_orig result |
#src ⇒ Object
113 114 115 |
# File 'lib/erbpp/line_number.rb', line 113 def src src_with_cpp_line end |
#src_orig ⇒ Object
111 |
# File 'lib/erbpp/line_number.rb', line 111 alias src_orig src |
#src_with_cpp_line ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/erbpp/line_number.rb', line 117 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+";_erbout.final;" end |