Closed ryechus closed 8 years ago
Looks pretty good. Nice tests too!
I removed the extra space. Let me know if you find anything else.
Nope. Looks solid.
Thanks @ryechus for finishing this off. A few small notes. I actually got this working and have been testing it in my production environment for the last month with the follow:
function isHelper(statement){
return !!((statement.path && statement.path.original) && (statement.type === 'SubExpression' || (statement.params && statement.params.length) || statement.hash));
}
So @ryechus solution is pretty much the same thing with the exception of the additional statement.path.original check. I don't remember the use case exactly of when that was used. Nested helper in a partial maybe? Anyways, if that pops up I believe that would be the solution.
In the long term, I made a patch request for Handlebars to better figure this out in their public function
Handlebar.AST.helpers.helperExpression
This looks like it will be fixed in Handlebars 4.0 but it might be a good idea to use the one tested by the Handlebars guys.
{code} helperExpression: function(node) { return (node.type === 'SubExpression') || ((node.type === 'MustacheStatement' || node.type === 'BlockStatement') && !!((node.params && node.params.length) || node.hash)); {code} https://github.com/wycats/handlebars.js/pull/1055
Thanks again
I started where @chrisrink left off and was able to fix the problems he was having pretty simply.