Sha256: fb3d17f9a885a086ab8faffa79b161f479748644de07a89f1b46ec581d3927cf
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
module Stache module AssetHelper # template_include_tag("widgets/basic_text_api_data") # template_include_tag("shared/test_thing") def template_include_tag(*sources) sources.collect do |source| exploded = source.split("/") file = exploded.pop file = file.split(".").first base_path = Stache.template_base_path.join(*exploded) template_path = locate_template_for(base_path, file) if template_path template = ::File.open(template_path, "rb" , :encoding => Rails.configuration.encoding) content_tag(:script, template.read.html_safe, :type => "text/html", :id => "#{file.dasherize.underscore}_template") else raise ActionView::MissingTemplate.new(potential_paths(base_path, file), file, [base_path], false, { :handlers => [:mustache] }) end end.join("\n").html_safe end def potential_paths(path, candidate_file_name) [ path.join("_#{candidate_file_name}.html.mustache"), path.join("_#{candidate_file_name}.mustache"), path.join("#{candidate_file_name}.html.mustache"), path.join("#{candidate_file_name}.mustache") ] end def locate_template_for(path, candidate_file_name) potential_paths(path, candidate_file_name).find { |file| File.file?(file.to_s) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stache-0.2.1 | lib/stache/asset_helper.rb |