Module: Cell::Erb
- Defined in:
- lib/cell/erb/template.rb,
lib/cell/erb/version.rb
Overview
Erb contains helpers that are messed up in Rails and do escaping.
Defined Under Namespace
Classes: Template
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Method Summary collapse
- #capture(*args) {|args| ... } ⇒ Object
- #concat(string) ⇒ Object
-
#content_tag(name, content_or_options_with_block = nil, options = nil, escape = false, &block) ⇒ Object
Below: Rails specific helper fixes.
- #form_tag_html(html_options) ⇒ Object
- #form_tag_with_body(html_options, content) ⇒ Object
-
#tag_options(options, escape = true) ⇒ Object
We do statically set escape=true since attributes are double-quoted strings, so we have to escape (default in Rails).
- #template_options_for(options) ⇒ Object
Instance Method Details
#capture(*args) {|args| ... } ⇒ Object
13 14 15 |
# File 'lib/cell/erb/template.rb', line 13 def capture(*args) yield(*args) end |
#concat(string) ⇒ Object
39 40 41 42 |
# File 'lib/cell/erb/template.rb', line 39 def concat(string) raise "[Cells-ERB] The #concat helper uses global state and is not supported anymore. Please change your code to simple `+` String concatenation or tell the gem authors to remove #concat usage." end |
#content_tag(name, content_or_options_with_block = nil, options = nil, escape = false, &block) ⇒ Object
Below: Rails specific helper fixes. I hate that. I can’t tell you how much I hate those helpers, and their blind escaping for every possible string within the application.
20 21 22 |
# File 'lib/cell/erb/template.rb', line 20 def content_tag(name, =nil, =nil, escape=false, &block) super end |
#form_tag_html(html_options) ⇒ Object
34 35 36 37 |
# File 'lib/cell/erb/template.rb', line 34 def form_tag_html() = () "#{tag(:form, , true) + }" end |
#form_tag_with_body(html_options, content) ⇒ Object
30 31 32 |
# File 'lib/cell/erb/template.rb', line 30 def form_tag_with_body(, content) "#{form_tag_html()}" << content.to_s << "</form>" end |
#tag_options(options, escape = true) ⇒ Object
We do statically set escape=true since attributes are double-quoted strings, so we have to escape (default in Rails).
26 27 28 |
# File 'lib/cell/erb/template.rb', line 26 def (, escape = true) super(, true) end |