Module: LiquidLoader::Context
- Defined in:
- lib/liquid_loader/context.rb
Instance Method Summary collapse
- #add_context(opts = nil) ⇒ Object
- #add_register(opts = nil) ⇒ Object
- #render_layout(template, context = nil) ⇒ Object
- #render_template(template, destination, context = nil) ⇒ Object
Instance Method Details
#add_context(opts = nil) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/liquid_loader/context.rb', line 16 def add_context(opts = nil) if opts.is_a? Hash opts.each do |k, v| liq[k.to_s.downcase] = v end end end |
#add_register(opts = nil) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/liquid_loader/context.rb', line 24 def add_register(opts = nil) if opts.is_a? Hash opts.each do |k, v| liq.registers[k.to_sym] = v end end end |
#render_layout(template, context = nil) ⇒ Object
6 7 8 9 |
# File 'lib/liquid_loader/context.rb', line 6 def render_layout(template, context = nil) ctx = (context ? context : liq) template.render(ctx) end |
#render_template(template, destination, context = nil) ⇒ Object
11 12 13 14 |
# File 'lib/liquid_loader/context.rb', line 11 def render_template(template, destination, context = nil) ctx = (context ? context : liq) add_context(destination => render_layout(template, ctx)) end |