Sha256: ec4761482c0ba6890ea3fd5752ae200ee9815d76e4fec402d6fff5bd7912f334

Contents?: true

Size: 1.23 KB

Versions: 17

Compression:

Stored size: 1.23 KB

Contents

module Stache
  # Basically a dumping ground for code that didn't fit anywhere else
  module Util
    # From HAML
    # Returns an ::ActionView::Template* class.
    # In pre-3.0 versions of Rails, most of these classes
    # were of the form `::ActionView::TemplateFoo`,
    # while afterwards they were of the form `::ActionView::Template::Foo`.
    #
    # @param name [#to_s] The name of the class to get.
    #   For example, `:Error` will return `::ActionView::TemplateError`
    #   or `::ActionView::Template::Error`.
    def self.av_template_class(name)
      if ::ActionView::Template.const_defined?(name)
        ::ActionView::Template.const_get(name)
      else
        ::ActionView.const_get("Template#{name}")
      end
    end
    
    def self.needs_compilable?
      (
        (defined?(::ActionView::TemplateHandlers) && defined?(::ActionView::TemplateHandlers::Compilable)) ||
        (defined?(::ActionView::Template) && defined?(::ActionView::Template::Handlers) && defined?(::ActionView::Template::Handlers::Compilable))
      ) &&
        # In Rails 3.1+, we don't need to include Compilable.
      Stache::Util.av_template_class(:Handlers)::ERB.include?( Stache::Util.av_template_class(:Handlers)::Compilable )
      
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
stache-1.2.0 lib/stache/util.rb
stache-1.1.1 lib/stache/util.rb
stache-1.1.0 lib/stache/util.rb
stache-1.0.3 lib/stache/util.rb
stache-1.0.2 lib/stache/util.rb
stache-1.0.1 lib/stache/util.rb
stache-1.0.0 lib/stache/util.rb
stache-1.0.0.rc lib/stache/util.rb
stache-0.9.1 lib/stache/util.rb
stache-0.9.0 lib/stache/util.rb
stache-0.2.2 lib/stache/util.rb
stache-0.2.1 lib/stache/util.rb
stache-0.2.0 lib/stache/util.rb
stache-0.1.0 lib/stache/util.rb
stache-0.0.3 lib/stache/util.rb
stache-0.0.2 lib/stache/util.rb
stache-0.0.1 lib/stache/util.rb