Skip to content

Commit

Permalink
[change] rename ':bufname' option to ':bufvar'
Browse files Browse the repository at this point in the history
  • Loading branch information
kwatch committed Mar 21, 2011
1 parent a383bfd commit cd532bf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions lib/erubis/engine/eruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module RubyGenerator
def init_generator(properties={})
super
@escapefunc ||= "Erubis::XmlHelper.escape_xml"
@bufname = properties[:bufname] || "_buf"
@bufvar = properties[:bufvar] || "_buf"
end

def self.supported_properties() # :nodoc:
Expand All @@ -38,12 +38,12 @@ def escaped_expr(code)

#--
#def add_preamble(src)
# src << "#{@bufname} = [];"
# src << "#{@bufvar} = [];"
#end
#++

def add_text(src, text)
src << " #{@bufname} << '" << escape_text(text) << "';" unless text.empty?
src << " #{@bufvar} << '" << escape_text(text) << "';" unless text.empty?
end

def add_stmt(src, code)
Expand All @@ -53,11 +53,11 @@ def add_stmt(src, code)
end

def add_expr_literal(src, code)
src << " #{@bufname} << (" << code << ').to_s;'
src << " #{@bufvar} << (" << code << ').to_s;'
end

def add_expr_escaped(src, code)
src << " #{@bufname} << " << escaped_expr(code) << ';'
src << " #{@bufvar} << " << escaped_expr(code) << ';'
end

def add_expr_debug(src, code)
Expand All @@ -68,7 +68,7 @@ def add_expr_debug(src, code)

#--
#def add_postamble(src)
# src << "\n#{@bufname}.join\n"
# src << "\n#{@bufvar}.join\n"
#end
#++

Expand Down
22 changes: 11 additions & 11 deletions lib/erubis/enhancer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def self.desc # :nodoc:
end

def add_preamble(src)
src << "#{@bufname} = $stdout;"
src << "#{@bufvar} = $stdout;"
end

def add_postamble(src)
Expand Down Expand Up @@ -162,12 +162,12 @@ def self.desc # :nodoc:
end

def add_preamble(src)
src << "#{@bufname} = [];"
src << "#{@bufvar} = [];"
end

def add_postamble(src)
src << "\n" unless src[-1] == ?\n
src << "#{@bufname}\n"
src << "#{@bufvar}\n"
end

end
Expand Down Expand Up @@ -208,12 +208,12 @@ def self.desc # :nodoc:
end

def add_preamble(src)
src << "#{@bufname} = '';"
src << "#{@bufvar} = '';"
end

def add_postamble(src)
src << "\n" unless src[-1] == ?\n
src << "#{@bufname}.to_s\n"
src << "#{@bufvar}.to_s\n"
end

end
Expand All @@ -231,12 +231,12 @@ def self.desc # :nodoc:
end

def add_preamble(src)
src << "#{@bufname} = StringIO.new;"
src << "#{@bufvar} = StringIO.new;"
end

def add_postamble(src)
src << "\n" unless src[-1] == ?\n
src << "#{@bufname}.string\n"
src << "#{@bufvar}.string\n"
end

end
Expand All @@ -254,12 +254,12 @@ def self.desc # :nodoc:
end

def add_preamble(src)
src << "_erbout = #{@bufname} = '';"
src << "_erbout = #{@bufvar} = '';"
end

def add_postamble(src)
src << "\n" unless src[-1] == ?\n
src << "#{@bufname}.to_s\n"
src << "#{@bufvar}.to_s\n"
end

end
Expand Down Expand Up @@ -698,9 +698,9 @@ def add_text(src, text)
#src << " _buf << %Q`" << text << "`;"
if text[-1] == ?\n
text[-1] = "\\n"
src << " #{@bufname} << %Q`#{text}`\n"
src << " #{@bufvar} << %Q`#{text}`\n"
else
src << " #{@bufname} << %Q`#{text}`;"
src << " #{@bufvar} << %Q`#{text}`;"
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/test-engines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _test()
- name: ruby2_options
lang: ruby
class: Eruby
options: { :bufname: '@_out_buf' }
options: { :bufvar: '@_out_buf' }
input: |
<table>
<% for item in @items %>
Expand Down

0 comments on commit cd532bf

Please sign in to comment.