Sha256: 5adaafc05177f64610c7da31d05ab9e83c06eaa18f42680664d57163050da0b2

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

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

require 'liquid'

module Ramaze::Template
  class Liquid < Template

    Ramaze::Controller.register_engine 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 controller, options = {}
        action, parameter, file, bound = *super

        reaction = controller.send(action, *parameter)
        template = reaction_or_file(reaction, file)

        return '' unless template

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ramaze-0.0.8 lib/ramaze/template/liquid.rb
ramaze-0.0.9 lib/ramaze/template/liquid.rb