Class: Malt::Engine::Liquid
- Defined in:
- lib/malt/engines/liquid.rb
Overview
Liquid templates.
Instance Attribute Summary
Attributes inherited from Abstract
Instance Method Summary collapse
- #create_engine(params = {}) ⇒ Object
-
#render(params = {}, &content) ⇒ Object
file, db, &content).
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
32 33 34 35 36 37 |
# File 'lib/malt/engines/liquid.rb', line 32 def create_engine(params={}) text = parameters(params, :text) cached(text) do ::Liquid::Template.parse(text) end end |
#render(params = {}, &content) ⇒ Object
file, db, &content)
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/malt/engines/liquid.rb', line 14 def render(params={}, &content) #file, db, &content) text, scope, locals = parameters(params, :text, :scope, :locals) data = make_hash(scope, locals, &content) # convert symbol keys to strings w/o rewriting the hash symbol_keys = data.keys.select{ |k| Symbol === k } symbol_keys.each do |k| data[k.to_s] = data[k] data.delete(k) end engine = prepare_engine(params) engine.render(data) end |