Skip to content

Commit

Permalink
Use the full partial name to avoid collisions between different direc…
Browse files Browse the repository at this point in the history
…tories.
  • Loading branch information
Rob Holland committed Nov 22, 2011
1 parent 4fe9cd8 commit 97501eb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/handlebars_assets/tilt_handlebars.rb
Expand Up @@ -11,14 +11,14 @@ def evaluate(scope, locals, &block)
compiled_hbs = Handlebars.precompile(data) compiled_hbs = Handlebars.precompile(data)


if name.starts_with?('_') if name.starts_with?('_')
partial_name = name[1..-1].inspect partial_name = scope.logical_path.sub(/#{name}$/, name[1..-1]).to_s
<<-PARTIAL <<-PARTIAL
(function() { (function() {
Handlebars.registerPartial(#{partial_name}, Handlebars.template(#{compiled_hbs})); Handlebars.registerPartial(#{partial_name}, Handlebars.template(#{compiled_hbs}));
}).call(this); }).call(this);
PARTIAL PARTIAL
else else
template_name = scope.logical_path.inspect template_name = scope.logical_path.to_s
<<-TEMPLATE <<-TEMPLATE
function(context) { function(context) {
return HandlebarsTemplates[#{template_name}](context); return HandlebarsTemplates[#{template_name}](context);
Expand All @@ -30,9 +30,9 @@ def evaluate(scope, locals, &block)
end end


protected protected

def basename(path) def basename(path)
path.gsub(%r{.*/}, '') path.sub(%r{.*/}, '')
end end


def prepare; end def prepare; end
Expand Down

0 comments on commit 97501eb

Please sign in to comment.