Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

template_include_tag helper resolves paths starting with "/" to absol…

…ute view folders
  • Loading branch information...
commit 75bb402411fb9c5301005dd2e4e0756b5be3867f 1 parent c0dff19
@ismasan ismasan authored
Showing with 14 additions and 3 deletions.
  1. +14 −3 lib/poirot/asset_helper.rb
View
17 lib/poirot/asset_helper.rb
@@ -2,10 +2,21 @@ module Poirot
module AssetHelper
def template_include_tag(*sources)
sources.collect do |source|
- template_path = Rails.root.join('app/views', controller_name, "_#{source}.html.mustache")
- template = File.open(template_path, "rb")
- content_tag :script, template.read.html_safe, :type => "text/mustache", :id => "#{source.dasherize}-template"
+ template = File.open(_poirot_resolve_partial_path(source), "rb")
+ content_tag :script, template.read.html_safe, :type => "text/mustache", :id => "#{source.parameterize}-template"
end.join("\n").html_safe
end
+
+ def _poirot_resolve_partial_path(source)
+ if source.to_s =~ /^\// # absolute path to a different view folder
+ segments = source.to_s.split('/')
+ partial_name = "_#{segments.pop}.html.mustache"
+ segments << partial_name
+ Rails.root.join('app/views', *segments)
+ else
+ Rails.root.join('app/views', controller_name, "_#{source}.html.mustache")
+ end
+ end
+
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.