Class | Tilt::LiquidTemplate |
In: |
lib/sinatra/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/sinatra/tilt.rb, line 595 595: def evaluate(scope, locals, &block) 596: locals = locals.inject({}){ |h,(k,v)| h[k.to_s] = v ; h } 597: if scope.respond_to?(:to_h) 598: scope = scope.to_h.inject({}){ |h,(k,v)| h[k.to_s] = v ; h } 599: locals = scope.merge(locals) 600: end 601: locals['yield'] = block.nil? ? '' : yield 602: locals['content'] = locals['yield'] 603: @engine.render(locals) 604: end