class Tilt::LiquidTemplate
Liquid template implementation. See: liquidmarkup.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.
Public Instance Methods
allows_script?()
click to toggle source
# File lib/tilt/liquid.rb, line 34 def allows_script? false end
evaluate(scope, locals) { || ... }
click to toggle source
# File lib/tilt/liquid.rb, line 23 def evaluate(scope, locals, &block) locals = locals.inject({}){ |h,(k,v)| h[k.to_s] = v ; h } if scope.respond_to?(:to_h) scope = scope.to_h.inject({}){ |h,(k,v)| h[k.to_s] = v ; h } locals = scope.merge(locals) end locals['yield'] = block.nil? ? '' : yield locals['content'] = locals['yield'] @engine.render(locals) end
prepare()
click to toggle source
# File lib/tilt/liquid.rb, line 19 def prepare @engine = ::Liquid::Template.parse(data, liquid_options) end
Private Instance Methods
liquid_options()
click to toggle source
# File lib/tilt/liquid.rb, line 40 def liquid_options { line_numbers: true }.merge options end