Module: Padrino::Rendering::Erubi::SafeBufferEnhancer

Included in:
SafeErubi
Defined in:
padrino-helpers/lib/padrino/rendering/erubi_template.rb

Instance Method Summary collapse

Instance Method Details

#add_expression_result(code) ⇒ Object


5
6
7
# File 'padrino-helpers/lib/padrino/rendering/erubi_template.rb', line 5

def add_expression_result(code)
  @src << " @__in_ruby_literal = true; #{bufvar}.concat((" << code << ').to_s); @__in_ruby_literal = false;'
end

#add_expression_result_escaped(code) ⇒ Object


9
10
11
# File 'padrino-helpers/lib/padrino/rendering/erubi_template.rb', line 9

def add_expression_result_escaped(code)
  @src << " #{bufvar}.safe_concat (" << code << ");"
end

#add_text(text) ⇒ Object


13
14
15
# File 'padrino-helpers/lib/padrino/rendering/erubi_template.rb', line 13

def add_text(text)
  @src << " #{bufvar}.safe_concat '" << text.gsub(/['\\]/, '\\\\\&') << "';" unless text.empty?
end