| Class | Tilt::LiquidTemplate |
| In: |
lib/tilt.rb
|
| Parent: | Template |
Liquid template implementation. See: liquid.rubyforge.org/
Liquid is designed to be a safe template system and threfore does not provide direct access to execuatable scopes. In order to support a scope, the scope must be able to represent itself as a hash by responding to to_h. If the scope does not respond to to_h it will be ignored.
LiquidTemplate does not support yield blocks.
It‘s suggested that your program require ‘liquid’ at load time when using this template engine.
# File lib/tilt.rb, line 715
715: def evaluate(scope, locals, &block)
716: locals = locals.inject({}){ |h,(k,v)| h[k.to_s] = v ; h }
717: if scope.respond_to?(:to_h)
718: scope = scope.to_h.inject({}){ |h,(k,v)| h[k.to_s] = v ; h }
719: locals = scope.merge(locals)
720: end
721: locals['yield'] = block.nil? ? '' : yield
722: locals['content'] = locals['yield']
723: @engine.render(locals)
724: end