diff options
author | makoto kuwata <kwa@kuwata-lab.com> | 2011-02-22 19:45:09 +0900 |
---|---|---|
committer | makoto kuwata <kwa@kuwata-lab.com> | 2011-02-22 19:45:33 +0900 |
commit | d735e2255ce102719cff1530fb6c138a76c62e4e (patch) | |
tree | 6d5461a6715477dacd928c451ab8b7c26462fc4f /lib/erubis/enhancer.rb | |
parent | d75b89a389e05424b91983a652596522a25baf5b (diff) | |
download | erubis-d735e2255ce102719cff1530fb6c138a76c62e4e.tar.gz |
[enhance] add new option ':bufname' to specify buffer variable name
Diffstat (limited to 'lib/erubis/enhancer.rb')
-rw-r--r-- | lib/erubis/enhancer.rb | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/erubis/enhancer.rb b/lib/erubis/enhancer.rb index d9b22a3..b6864eb 100644 --- a/lib/erubis/enhancer.rb +++ b/lib/erubis/enhancer.rb @@ -67,7 +67,7 @@ module Erubis end def add_preamble(src) - src << "_buf = $stdout;" + src << "#{@bufname} = $stdout;" end def add_postamble(src) @@ -162,12 +162,12 @@ module Erubis end def add_preamble(src) - src << "_buf = [];" + src << "#{@bufname} = [];" end def add_postamble(src) src << "\n" unless src[-1] == ?\n - src << "_buf\n" + src << "#{@bufname}\n" end end @@ -208,12 +208,12 @@ module Erubis end def add_preamble(src) - src << "_buf = '';" + src << "#{@bufname} = '';" end def add_postamble(src) src << "\n" unless src[-1] == ?\n - src << "_buf.to_s\n" + src << "#{@bufname}.to_s\n" end end @@ -231,12 +231,12 @@ module Erubis end def add_preamble(src) - src << "_buf = StringIO.new;" + src << "#{@bufname} = StringIO.new;" end def add_postamble(src) src << "\n" unless src[-1] == ?\n - src << "_buf.string\n" + src << "#{@bufname}.string\n" end end @@ -254,12 +254,12 @@ module Erubis end def add_preamble(src) - src << "_erbout = _buf = '';" + src << "_erbout = #{@bufname} = '';" end def add_postamble(src) src << "\n" unless src[-1] == ?\n - src << "_buf.to_s\n" + src << "#{@bufname}.to_s\n" end end @@ -654,9 +654,9 @@ module Erubis #src << " _buf << %Q`" << text << "`;" if text[-1] == ?\n text[-1] = "\\n" - src << " _buf << %Q`" << text << "`\n" + src << " #{@bufname} << %Q`" << text << "`\n" else - src << " _buf << %Q`" << text << "`;" + src << " #{@bufname} << %Q`" << text << "`;" end end |