Sha256: 69647cff1ed6a1c90b61fad861ac4b5d1cbad9c4a78cb43f58d8aa9825fad2c9

Contents?: true

Size: 783 Bytes

Versions: 7

Compression:

Stored size: 783 Bytes

Contents

# encoding: utf-8

require "tilt"

module TemplateInheritance
  module TiltExtensions
    # Tilt::HamlTemplate.options[:default_attributes] = {script: {type: "text/javascript"}, form: {method: "POST"}}
    module Haml
      def self.included(klass)
        klass.send(:remove_method, :initialize_engine)
        def klass.options
          @options ||= Hash.new
        end
      end

      def initialize_engine
        require_template_library 'haml' unless defined? ::Haml::Engine
        require "template-inheritance/exts/haml" if self.class.options[:default_attributes]
      end

      def initialize(*args)
        super
        self.options.merge!(self.class.options)
      end
    end
  end
end

Tilt::HamlTemplate.send(:include, TemplateInheritance::TiltExtensions::Haml)

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
template-inheritance-0.3.1 lib/template-inheritance/exts/tilt.rb
template-inheritance-0.3 lib/template-inheritance/exts/tilt.rb
template-inheritance-0.2 lib/template-inheritance/exts/tilt.rb
template-inheritance-0.1.3 lib/template-inheritance/exts/tilt.rb
template-inheritance-0.1.2 lib/template-inheritance/exts/tilt.rb
template-inheritance-0.1.1 lib/template-inheritance/exts/tilt.rb
template-inheritance-0.1 lib/template-inheritance/exts/tilt.rb