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 715
715:     def evaluate(scope, locals, &block)
716:       locals = locals.inject({}){ |h,(k,v)| h[k.to_s] = v ; h }
717:       if scope.respond_to?(:to_h)
718:         scope  = scope.to_h.inject({}){ |h,(k,v)| h[k.to_s] = v ; h }
719:         locals = scope.merge(locals)
720:       end
721:       locals['yield'] = block.nil? ? '' : yield
722:       locals['content'] = locals['yield']
723:       @engine.render(locals)
724:     end

[Source]

     # File lib/tilt.rb, line 706
706:     def initialize_engine
707:       return if defined? ::Liquid::Template
708:       require_template_library 'liquid'
709:     end

[Source]

     # File lib/tilt.rb, line 711
711:     def prepare
712:       @engine = ::Liquid::Template.parse(data)
713:     end

[Validate]