Skip to content

Fix helpers with recent Handlebars and improve server-side compatibility#4

Open
chromakode wants to merge 3 commits intoloicfrering:masterfrom
chromakode:master
Open

Fix helpers with recent Handlebars and improve server-side compatibility#4
chromakode wants to merge 3 commits intoloicfrering:masterfrom
chromakode:master

Conversation

@chromakode
Copy link

I believe I've discovered a fix for #2 while hacking around running this module server-side tonight. It looks like Handlebars is applying the nameLookup function to helper lookups now, generating code like this:

+ escapeExpression((helper = helpers.get ? helpers.get('view') : helpers.view || depth0.get ? depth0.get('view') : (depth0 && depth0.view),options={...

I'd guess that order of operations is causing this to have an unexpected result. Surrounding the nameLookup output with parentheses got things working again. :)

Handlebars helpers were broken due to `nameLookup` generating an
unexpected ternary in the compiled code's helper lookup expression.
This eases compatibility with jQuery analogues like cheerio.
This helps when running in a non-browser environment like node.
@loicfrering
Copy link
Owner

Awesome, thanks a lot @chromakode!

In order to be merged, could you please update the according test to get a successful build on Travis CI?

@chromakode
Copy link
Author

Sorry, missed your reply for some reason. Will do!

@loicfrering
Copy link
Owner

Great, 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