Sha256: 22e234d6270dd39241cf3b7208094f266749f16bc504ce316f46bf7f935e4957

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 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 'ramaze/template/ezamar/engine'

module Ramaze
  module Template

    # Is responsible for compiling a template using the Ezamar templating engine.

    class Ezamar < Template

      Ramaze::Controller.register_engine self, %w[ xhtml zmr ]

      trait :transform_pipeline => [
        ::Ezamar::Element, ::Ezamar::Template
      ]

      trait :actionless => true

      class << self

        # Takes a controller and the options :action, :parameter, :file and :binding
        #
        # Uses Ezamar::Template to compile the template.

        def transform action
          template = reaction_or_file(action)
          file = (action.template || __FILE__)
          pipeline(template.to_s, action.binding, file)
        end

        # go through the pipeline and call #transform on every object found there,
        # passing the template at that point.
        # the order and contents of the pipeline are determined by an array
        # in trait[:template_pipeline]
        # the default being [Element, Morpher, self]
        #
        # TODO
        #   - put the pipeline into the Controller for use with all templates.

        def pipeline(template, binding, file)
          class_trait[:transform_pipeline].each do |klass|
            template = klass.transform(template, binding, file)
          end

          template
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ramaze-0.1.1 lib/ramaze/template/ezamar.rb