Sha256: 3e488431254b21078e396015f7c7b5ce0c388bd2f05a1530fac449dc20d29085

Contents?: true

Size: 958 Bytes

Versions: 3

Compression:

Stored size: 958 Bytes

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 'erubis'

module Ramaze::Template

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

  class Erubis < Template

    Ramaze::Controller.register_engine self, %w[ rhtml ]

    class << self

      # Takes a controller and the options :action, :parameter, :file and :binding
      #
      # Builds a template out of the method on the controller and the
      # template-file.

      def transform controller, options = {}
        action, parameter, file, bound = *super

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

        return '' unless template

        eruby = ::Erubis::Eruby.new(template)
        eruby.init_evaluator(:filename => file) if file
        eruby.result(bound)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ramaze-0.0.9 lib/ramaze/template/erubis.rb
ramaze-0.0.8 lib/ramaze/template/erubis.rb
ramaze-0.1.0 lib/ramaze/template/erubis.rb