Class: Malt::Engine::Erubis
- Defined in:
- lib/malt/engines/erubis.rb
Overview
Erubis template implementation.
http://www.kuwata-lab.com/erubis/
Erubis is essentially compatibel with ERB, but it is faster.
Instance Attribute Summary
Attributes inherited from Abstract
Instance Method Summary collapse
- #create_engine(params = {}) ⇒ Object
-
#render(params, &content) ⇒ Object
Render 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
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/malt/engines/erubis.rb', line 33 def create_engine(params={}) text, file, esc = parameters(params, :text, :file, :escape_html) opts = (params) cached(text, file, esc, opts) do if esc ::Erubis::EscapedEruby.new(text, opts) else ::Erubis::Eruby.new(text, opts) end end end |
#render(params, &content) ⇒ Object
Render template.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/malt/engines/erubis.rb', line 16 def render(params, &content) text, file, scope, locals = parameters(params, :text, :file, :scope, :locals) # NOTE: Erubis can handle hash data via result(:list=>data). # Would it be better to use that? bind = make_binding(scope, locals, &content) prepare_engine(params).result(bind) end |