Sha256: 719fc4ca1c865e1eb6ff56222e90e3c1e5628fc0cddd73ee8b33d918386615b6

Contents?: true

Size: 702 Bytes

Versions: 1

Compression:

Stored size: 702 Bytes

Contents

require 'malt/engines/abstract'

module Malt::Engines

  # Liquid
  #
  #   http://liquid.rubyforge.org/
  #
  class Liquid < Abstract

    default :liquid

    #
    def intermediate(params)
      text = params[:text]
      ::Liquid::Template.parse(text)
    end

    #
    def render(params={}, &yld) #file, db, &yld)
      text = params[:text]
      data = params[:data]
      data = make_hash(data, &yld)
      data = data.rekey{ |k| k.to_s }
      engine = intermediate(params)
      engine.render(data)
    end

    private

    # Load Liquid library if not already loaded.
    def initialize_engine
      return if defined? ::Liquid::Template
      require_library 'liquid'
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
malt-0.1.0 lib/malt/engines/liquid.rb