Sha256: 359b237e98881fbee59513ef2c350eadf1db3c319bf9e425483853e57fd751af

Contents?: true

Size: 1.26 KB

Versions: 50

Compression:

Stored size: 1.26 KB

Contents

unless Object.const_defined?(:Rails)
  raise "Rails is not loaded - Temple::Templates::Rails cannot be used"
end

if ::Rails::VERSION::MAJOR < 3
  raise "Temple supports only Rails 3.x and greater, your Rails version is #{::Rails::VERSION::STRING}"
end

module Temple
  module Templates
    if ::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR < 1
      class Rails < ActionView::TemplateHandler
        include ActionView::TemplateHandlers::Compilable
        extend Mixins::Template

        def compile(template)
          self.class.build_engine(:streaming => false, # Overwrite option: No streaming support in Rails < 3.1
                                  :file => template.identifier).call(template.source)
        end

        def self.register_as(name)
          ActionView::Template.register_template_handler name.to_sym, self
        end
      end
    else
      class Rails
        extend Mixins::Template

        def call(template)
          self.class.build_engine(:file => template.identifier).call(template.source)
        end

        def supports_streaming?
          self.class.default_options[:streaming]
        end

        def self.register_as(name)
          ActionView::Template.register_template_handler name.to_sym, new
        end
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 2 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/temple-0.4.0/lib/temple/templates/rails.rb
classiccms-0.7.4 vendor/bundle/gems/temple-0.4.0/lib/temple/templates/rails.rb
classiccms-0.7.3 vendor/bundle/gems/temple-0.4.0/lib/temple/templates/rails.rb
classiccms-0.7.2 vendor/bundle/gems/temple-0.4.0/lib/temple/templates/rails.rb
classiccms-0.7.1 vendor/bundle/gems/temple-0.4.0/lib/temple/templates/rails.rb
classiccms-0.7.0 vendor/bundle/gems/temple-0.4.0/lib/temple/templates/rails.rb
classiccms-0.6.9 vendor/bundle/gems/temple-0.4.0/lib/temple/templates/rails.rb
classiccms-0.6.8 vendor/bundle/gems/temple-0.4.0/lib/temple/templates/rails.rb
classiccms-0.6.7 vendor/bundle/gems/temple-0.4.0/lib/temple/templates/rails.rb
classiccms-0.6.6 vendor/bundle/gems/temple-0.4.0/lib/temple/templates/rails.rb
classiccms-0.6.5 vendor/bundle/gems/temple-0.4.0/lib/temple/templates/rails.rb
classiccms-0.6.4 vendor/bundle/gems/temple-0.4.0/lib/temple/templates/rails.rb
classiccms-0.6.3 vendor/bundle/gems/temple-0.4.0/lib/temple/templates/rails.rb
classiccms-0.6.2 vendor/bundle/gems/temple-0.4.0/lib/temple/templates/rails.rb
classiccms-0.6.1 vendor/bundle/gems/temple-0.4.0/lib/temple/templates/rails.rb
classiccms-0.6.0 vendor/bundle/gems/temple-0.4.0/lib/temple/templates/rails.rb
classiccms-0.5.17 vendor/bundle/gems/temple-0.4.0/lib/temple/templates/rails.rb
classiccms-0.5.16 vendor/bundle/gems/temple-0.4.0/lib/temple/templates/rails.rb
classiccms-0.5.15 vendor/bundle/gems/temple-0.4.0/lib/temple/templates/rails.rb
classiccms-0.5.14 vendor/bundle/gems/temple-0.4.0/lib/temple/templates/rails.rb