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.

Methods

Public Instance methods

[Source]

     # File lib/tilt.rb, line 709
709:     def evaluate(scope, locals, &block)
710:       locals = locals.inject({}){ |h,(k,v)| h[k.to_s] = v ; h }
711:       if scope.respond_to?(:to_h)
712:         scope  = scope.to_h.inject({}){ |h,(k,v)| h[k.to_s] = v ; h }
713:         locals = scope.merge(locals)
714:       end
715:       locals['yield'] = block.nil? ? '' : yield
716:       locals['content'] = locals['yield']
717:       @engine.render(locals)
718:     end

[Source]

     # File lib/tilt.rb, line 700
700:     def initialize_engine
701:       return if defined? ::Liquid::Template
702:       require_template_library 'liquid'
703:     end

[Source]

     # File lib/tilt.rb, line 705
705:     def prepare
706:       @engine = ::Liquid::Template.parse(data)
707:     end

[Validate]