Class: Tilt::LiquidTemplate

### Home Classes Methods

### In Files

- lib/tilt/liquid.rb

### Parent

Template

### Methods

- ::engine_initialized?
- #allows_script?
- #evaluate
- #initialize_engine
- #prepare

### Class/Module Index

Quicksearch

- Tilt
- Tilt::AsciidoctorTemplate
- Tilt::BlueClothTemplate
- Tilt::BuilderTemplate
- Tilt::CSVTemplate
- Tilt::Cache
- Tilt::CoffeeScriptTemplate
- Tilt::CompileSite
- Tilt::CreoleTemplate
- Tilt::ERBTemplate
- Tilt::ErubisTemplate
- Tilt::EtanniTemplate
- Tilt::HamlTemplate
- Tilt::KramdownTemplate
- Tilt::LessTemplate
- Tilt::LiquidTemplate
- Tilt::MarkabyTemplate
- Tilt::MarukuTemplate
- Tilt::NokogiriTemplate
- Tilt::PlainTemplate
- Tilt::RDiscountTemplate
- Tilt::RDocTemplate
- Tilt::RadiusTemplate
- Tilt::RedClothTemplate
- Tilt::RedcarpetTemplate
- Tilt::RedcarpetTemplate::Redcarpet1
- Tilt::RedcarpetTemplate::Redcarpet2
- Tilt::SassTemplate
- Tilt::ScssTemplate
- Tilt::StringTemplate
- Tilt::Template
- Tilt::WikiClothTemplate
- Tilt::YajlTemplate

No matching classes.

# 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 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 Class Methods

engine_initialized?() click to toggle source

    # File lib/tilt/liquid.rb, line 18
    def self.engine_initialized?
      defined? ::Liquid::Template
    end

### Public Instance Methods

allows_script?() click to toggle source

    # File lib/tilt/liquid.rb, line 41
    def allows_script?
      false
    end

evaluate(scope, locals, &block) click to toggle source

    # File lib/tilt/liquid.rb, line 30
    def evaluate(scope, locals, &block)
      locals = locals.inject({}){ |h,(k,v)| h[k.to_s] = v ; h }
      if scope.respond_to?(:to_h)
        scope  = scope.to_h.inject({}){ |h,(k,v)| h[k.to_s] = v ; h }
        locals = scope.merge(locals)
      end
      locals['yield'] = block.nil? ? '' : yield
      locals['content'] = locals['yield']
      @engine.render(locals)
    end

initialize_engine() click to toggle source

    # File lib/tilt/liquid.rb, line 22
    def initialize_engine
      require_template_library 'liquid'
    end

prepare() click to toggle source

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.