Tilt::LiquidTemplate

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 #. If the scope does not respond to # 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

evaluate(scope, locals, &block) click to toggle source
     # File lib/sinatra/tilt.rb, line 590
590:     def evaluate(scope, locals, &block)
591:       locals = locals.inject({}){ |h,(k,v)| h[k.to_s] = v ; h }
592:       if scope.respond_to?(:to_h)
593:         scope  = scope.to_h.inject({}){ |h,(k,v)| h[k.to_s] = v ; h }
594:         locals = scope.merge(locals)
595:       end
596:       locals['yield'] = block.nil? ? '' : yield
597:       locals['content'] = locals['yield']
598:       @engine.render(locals)
599:     end
initialize_engine() click to toggle source
     # File lib/sinatra/tilt.rb, line 581
581:     def initialize_engine
582:       return if defined? ::Liquid::Template
583:       require_template_library 'liquid'
584:     end
prepare() click to toggle source
     # File lib/sinatra/tilt.rb, line 586
586:     def prepare
587:       @engine = ::Liquid::Template.parse(data)
588:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.