Class: ActionView::Template::Handlers::Erubis
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Erubis::Eruby
|
|
Instance Chain:
self,
Erubis::Eruby
|
|
Inherits: |
Erubis::Eruby
|
Defined in: | actionview/lib/action_view/template/handlers/erb.rb |
Constant Summary
-
BLOCK_EXPR =
# File 'actionview/lib/action_view/template/handlers/erb.rb', line 38/\s*((\s+|\))do|\{)(\s*\|[^|]*\|)?\s*\Z/
Instance Method Summary
-
#add_expr(src, code, indicator)
Erubis
toggles <%= and <%== behavior when escaping is enabled. - #add_expr_escaped(src, code)
- #add_expr_literal(src, code)
- #add_postamble(src)
- #add_preamble(src)
- #add_stmt(src, code)
- #add_text(src, text)
- #flush_newline_if_pending(src)
Instance Method Details
#add_expr(src, code, indicator)
Erubis
toggles <%= and <%== behavior when escaping is enabled. We override to always treat <%== as escaped.
# File 'actionview/lib/action_view/template/handlers/erb.rb', line 29
def add_expr(src, code, indicator) case indicator when '==' add_expr_escaped(src, code) else super end end
#add_expr_escaped(src, code)
[ GitHub ]# File 'actionview/lib/action_view/template/handlers/erb.rb', line 49
def add_expr_escaped(src, code) flush_newline_if_pending(src) if code =~ BLOCK_EXPR src << "@output_buffer.safe_expr_append= " << code else src << "@output_buffer.safe_expr_append=(" << code << ");" end end
#add_expr_literal(src, code)
[ GitHub ]# File 'actionview/lib/action_view/template/handlers/erb.rb', line 40
def add_expr_literal(src, code) flush_newline_if_pending(src) if code =~ BLOCK_EXPR src << '@output_buffer.append= ' << code else src << '@output_buffer.append=(' << code << ');' end end
#add_postamble(src)
[ GitHub ]# File 'actionview/lib/action_view/template/handlers/erb.rb', line 63
def add_postamble(src) flush_newline_if_pending(src) src << '@output_buffer.to_s' end
#add_preamble(src)
[ GitHub ]# File 'actionview/lib/action_view/template/handlers/erb.rb', line 7
def add_preamble(src) @newline_pending = 0 src << "@output_buffer = output_buffer || ActionView::OutputBuffer.new;" end
#add_stmt(src, code)
[ GitHub ]# File 'actionview/lib/action_view/template/handlers/erb.rb', line 58
def add_stmt(src, code) flush_newline_if_pending(src) super end
#add_text(src, text)
[ GitHub ]# File 'actionview/lib/action_view/template/handlers/erb.rb', line 12
def add_text(src, text) return if text.empty? if text == "\n" @newline_pending += 1 else src << "@output_buffer.safe_append='" src << "\n" * @newline_pending if @newline_pending > 0 src << escape_text(text) src << "'.freeze;" @newline_pending = 0 end end
#flush_newline_if_pending(src)
[ GitHub ]# File 'actionview/lib/action_view/template/handlers/erb.rb', line 68
def flush_newline_if_pending(src) if @newline_pending > 0 src << "@output_buffer.safe_append='#{"\n" * @newline_pending}'.freeze;" @newline_pending = 0 end end