Sha256: ae8d4171e13046cc093ac3892e67be243ed13a88d5b3fa18e7e9ca6c529ba43b

Contents?: true

Size: 851 Bytes

Versions: 3

Compression:

Stored size: 851 Bytes

Contents

require "ice/eco_template/base"

module Ice
  module EcoTemplate
    class Handler < ActionView::Template::Handler
      def self.call(template)
        <<-ECO
          
          template_source = <<-ECO_TEMPLATE
            #{template.source}
          ECO_TEMPLATE

          variable_names = controller.instance_variable_names
          variable_names -= %w[@template]
          if controller.respond_to?(:protected_instance_variables)
            variable_names -= controller.protected_instance_variables
          end
          
          variables = {}
          variable_names.each do |name|
            variables[name.sub(/^@/, "")] = controller.instance_variable_get(name)
          end
          
          Ice::EcoTemplate.convert_template(template_source, variables.merge(local_assigns))
        
        ECO
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ice-0.4.4 lib/ice/eco_template/handler.rb
ice-0.4.3 lib/ice/eco_template/handler.rb
ice-0.4.2 lib/ice/eco_template/handler.rb