-
Notifications
You must be signed in to change notification settings - Fork 479
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
Passing Context objects through express does not work #743
Comments
Here's the issue: https://github.com/expressjs/express/blob/master/lib/application.js#L535 A new object, It's very interesting that no one has ever run into this before. I would never have expected Express to mangle a context object passed to it. We can fix this by dropping the instanceof check on our end. |
Hoffman even does the same (IMO incorrect) behavior in their
|
While we patch this you could manually stream your templates: https://github.com/linkedin/dustjs/blob/master/examples/streaming/app.js You'll just have to define |
Thanks Seth, appreciate the responses + effort involved. I thought I was doing something wrong, as like you say, very strange that this is the first time this has been run into. Then again, most examples exclusively use plain objects for their view models so perhaps that's why? Anyway, thanks again. Will patch my version while I wait for your patch to hit! |
Thanks for taking the time to report! I'm actually really fascinated that this has never been a problem before. I wonder if Express 4 changed the way that they merge options and locals. |
Not a problem at all. Could not for the life of me understand what I was doing wrong. Thanks again, got everything working in my project now and no need for consolidate/hoffman now. 🎉 |
This is available as 2.7.4. |
I've been having an extended discussion on StackOverflow (link) with @sethkinast regarding passing Context objects through Express.
I have put together a very quick example of how to replicate this issue here: https://github.com/adamkdean/dust-test
But to save time, the script is this:
If you go to
/pojo
then the plain old JavaScript object renders fine (the template is{#people}<li>{name} aged {age}</li>{/people}
), but if you go to/context
then it doesn't render fine at all.I think this would probably be a better place to discuss the issue.
The text was updated successfully, but these errors were encountered: