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

contentFor yields strange results when combined with asyncHelper #55

Closed
halfdan opened this issue Feb 8, 2014 · 6 comments
Closed

contentFor yields strange results when combined with asyncHelper #55

halfdan opened this issue Feb 8, 2014 · 6 comments

Comments

@halfdan
Copy link
Contributor

halfdan commented Feb 8, 2014

We currently experience a weird issue with an asynchronous helper when it is used inside a contentFor. (TryGhost/Ghost#2127)

I wrote a small app that demonstrates the issue at: https://github.com/halfdan/hbs-weird

The output looks like the following:

Weird express-hbs behaviour

Unexpected behaviour: __CoHMbGlL__

Strangely not so weird

12

Instead of getting 12 as output for both usages of the {{weird}} helper the one used in the contentFor returns a hash of some kind. I managed to track it down to being the result of the following line: https://github.com/barc/express-hbs/blob/master/lib/hbs.js#L566 which seems to return the shown value as a string (changes for every request).

@mgutz
Copy link

mgutz commented Feb 8, 2014

That looks like the placeholder ID for the async helper, which replaced when the promise completes. I'll look tomorrow.

@halfdan
Copy link
Contributor Author

halfdan commented Feb 8, 2014

It's also worth to note that the line at https://github.com/halfdan/hbs-weird/blob/master/views/index.hbs#L3 does not show up in the output.

@mgutz
Copy link

mgutz commented Feb 8, 2014

The missing line is due to {{{body}}} missing in the layout.

The problem was blocks in the layout were not checking for async results. Please checkout the branch issue-53 which should fix the issue. See the file test/issues.js for issue-53. If all is well, I will merge.

@halfdan
Copy link
Contributor Author

halfdan commented Feb 8, 2014

@mgutz Seems to work perfectly! So I'm 👍 for the merge.

@mgutz mgutz closed this as completed Feb 8, 2014
@halfdan
Copy link
Contributor Author

halfdan commented Feb 8, 2014

@mgutz Unfortunately we discovered another related issue just a few minutes ago. When using an async helper inside a block and passing it as a parameter to another helper, the same issue still seems to appear.

TryGhost/Ghost#2155 (comment)

@mgutz
Copy link

mgutz commented Feb 9, 2014

Please update your example project or edit the test and I'll try fixing.

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

No branches or pull requests

2 participants