Sha256: 87904a8b2214b594cf1f1653bf55b9b5a7217c3ef5180ca9ebfb3c253224fc8e

Contents?: true

Size: 1.05 KB

Versions: 22

Compression:

Stored size: 1.05 KB

Contents

#          Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
# All files in this distribution are subject to the terms of the Ruby license.

require 'liquid'

module Ramaze
  module Template

    # Is responsible for compiling a template using the Liquid templating engine.
    # Can be found at: http://home.leetsoft.com/liquid

    class Liquid < Template

      ENGINES[self] = %w[ liquid ]

      class << self

        # initializes the handling of a request on the controller.
        # Creates a new instances of itself and sends the action and params.
        # Also tries to render the template.
        # In Theory you can use this standalone, this has not been tested though.

        def transform action
          template = reaction_or_file(action)

          instance = action.instance
          hash     = instance.instance_variable_get("@hash") || {}
          template = ::Liquid::Template.parse(template)
          options  = instance.ancestral_trait[:liquid_options]

          template.render(hash, options)
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 5 rubygems

Version Path
ramaze-2009.03 lib/ramaze/template/liquid.rb
ramaze-2009.02 lib/ramaze/template/liquid.rb