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.
Public Instance Methods
allows_script?()
click to toggle source
# File lib/tilt/liquid.rb 33 def allows_script? 34 false 35 end
evaluate(scope, locs) { |: ''| ... }
click to toggle source
# File lib/tilt/liquid.rb 22 def evaluate(scope, locs) 23 locals = {} 24 if scope.respond_to?(:to_h) 25 scope.to_h.each{|k, v| locals[k.to_s] = v} 26 end 27 locs.each{|k, v| locals[k.to_s] = v} 28 locals['yield'] = block_given? ? yield : '' 29 locals['content'] = locals['yield'] 30 @engine.render(locals) 31 end
prepare()
click to toggle source
# File lib/tilt/liquid.rb 17 def prepare 18 @options[:line_numbers] = true unless @options.has_key?(:line_numbers) 19 @engine = ::Liquid::Template.parse(@data, @options) 20 end