Sha256: 51608bd2f3ccce147b9b817bdbf2340144dcd54e080d4e66f448d9e58be64783

Contents?: true

Size: 949 Bytes

Versions: 3

Compression:

Stored size: 949 Bytes

Contents

module Stache
  module AssetHelper
    # template_include_tag("widgets/basic_text_api_data")
    # template_include_tag("shared/test_thing")
    def template_include_tag(*sources)
      options = sources.extract_options!
      sources.collect do |source|
        template_finder = lambda do |partial|
          if ActionPack::VERSION::MAJOR == 3 && ActionPack::VERSION::MINOR < 2
            lookup_context.find(source, [], partial)
          else # Rails 3.2 and higher
            lookup_context.find(source, [], partial, [], { formats: [:html] })
          end
        end

        template = template_finder.call(true) rescue template_finder.call(false)
        template_id = (Stache.include_path_in_id) ? source.gsub("/", '_') : source.to_s.split("/").last
        content_tag(:script, template.source.html_safe, options.reverse_merge(type: 'text/html', id: template_id.dasherize.underscore))

      end.join("\n").html_safe
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stache-1.2.0 lib/stache/asset_helper.rb
stache-1.1.1 lib/stache/asset_helper.rb
stache-1.1.0 lib/stache/asset_helper.rb