Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix required for 458, paths that begin with './' #459

Merged
merged 2 commits into from
Apr 6, 2013

Conversation

jpfiset
Copy link
Contributor

@jpfiset jpfiset commented Mar 4, 2013

avoid name collisions with registered helper functions.

Issue #458

@kpdecker
Copy link
Collaborator

kpdecker commented Apr 6, 2013

This seems like a useful change but I don't think it quite works as expected as this test is failing.

test('GH-458: Scoped this identifier', function() {
  shouldCompileTo('./foo', {foo: 'bar'}, 'bar');
});

@kpdecker kpdecker merged commit 681f1a6 into handlebars-lang:master Apr 6, 2013
@kpdecker
Copy link
Collaborator

kpdecker commented Apr 6, 2013

And immediately after I make that post I see my mistake in the test :/ After fixing my error there everything is green.

Bonus here as this provides optimized output for the precompiler when not using known helpers mode.

require('./lib/handlebars').precompile('{{./foo}}')
'function (Handlebars,depth0,helpers,partials,data) {\n this.compilerInfo = [2,'>= 1.0.0-rc.3'];\nhelpers = helpers || Handlebars.helpers; data = data || {};\n var stack1, functionType="function", escapeExpression=this.escapeExpression;\n\n\n return escapeExpression(((stack1 = depth0.foo),typeof stack1 === functionType ? stack1.apply(depth0) : stack1));\n }'

require('./lib/handlebars').precompile('{{foo}}')
'function (Handlebars,depth0,helpers,partials,data) {\n this.compilerInfo = [2,'>= 1.0.0-rc.3'];\nhelpers = helpers || Handlebars.helpers; data = data || {};\n var stack1, functionType="function", escapeExpression=this.escapeExpression;\n\n\n if (stack1 = helpers.foo) { stack1 = stack1.call(depth0, {hash:{},data:data}); }\n else { stack1 = depth0.foo; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }\n return escapeExpression(stack1);\n }'

Just merged this. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants