Module: Padrino::Rendering::SafeBufferEnhancer Private

Included in:
SafeEruby
Defined in:
lib/padrino/rendering/erubis_template.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

SafeBufferEnhancer is an Erubis Enhancer that compiles templates that are fit for using SafeBuffer as a Buffer.

Instance Method Summary collapse

Instance Method Details

#add_expr_escaped(src, code) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



19
20
21
# File 'lib/padrino/rendering/erubis_template.rb', line 19

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

#add_expr_literal(src, code) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



9
10
11
# File 'lib/padrino/rendering/erubis_template.rb', line 9

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

#add_stmt(src, code) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



13
14
15
16
17
# File 'lib/padrino/rendering/erubis_template.rb', line 13

def add_stmt(src, code)
  code = code.sub('end', 'nil;end') if code =~ /\A\s*end\s*\Z/
  src << code
  src << ';' unless code[-1] == ?\n
end

#add_text(src, text) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



23
24
25
# File 'lib/padrino/rendering/erubis_template.rb', line 23

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