Class: Malt::Engine::Erb
Overview
ERB template implementation.
http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html
ERB templates accept two options. safe
sets the safe mode for rendering the template and trim
is a weird string that controls a few rendering options –it can be ‘%’ and/or ‘>’ or ‘<>’.
Instance Attribute Summary
Attributes inherited from Abstract
Instance Method Summary collapse
- #create_engine(params = {}) ⇒ Object
-
#render(params = {}, &content) ⇒ String
Render ERB template.
Methods inherited from Abstract
#cache?, default, #initialize, #prepare_engine, register, type
Constructor Details
This class inherits a constructor from Malt::Engine::Abstract
Instance Method Details
#create_engine(params = {}) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/malt/engines/erb.rb', line 64 def create_engine(params={}) text = parameters(params, :text) opts = (params) safe = opts[:safe] trim = opts[:trim] cached(text,safe,trim) do ::ERB.new(text, safe, trim) end end |
#render(params = {}, &content) ⇒ String
Render ERB template.
48 49 50 51 52 53 54 55 56 |
# File 'lib/malt/engines/erb.rb', line 48 def render(params={}, &content) text, file, scope, locals = parameters(params, :text, :file, :scope, :locals) #if settings[:compile] == true #else bind = make_binding(scope, locals, &content) prepare_engine(params).result(bind) #end end |