class Tilt::LiquidTemplate

Liquid template implementation. See: liquidmarkup.org/

Liquid is designed to be a safe template system and therefore 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
36 def allows_script?
37   false
38 end
evaluate(scope, locs) { |: ''| ... } click to toggle source
   # File lib/tilt/liquid.rb
25 def evaluate(scope, locs)
26   locals = {}
27   if scope.respond_to?(:to_h)
28     scope.to_h.each{|k, v| locals[k.to_s] = v}
29   end
30   locs.each{|k, v| locals[k.to_s] = v}
31   locals['yield'] = block_given? ? yield : ''
32   locals['content'] = locals['yield']
33   @engine.render(locals)
34 end
prepare() click to toggle source
   # File lib/tilt/liquid.rb
20 def prepare
21   @options[:line_numbers] = true unless @options.has_key?(:line_numbers)
22   @engine = ::Liquid::Template.parse(@data, @options)
23 end