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

Ability to access request extensions in Helpers #51

Open
untitaker opened this issue Sep 18, 2016 · 2 comments
Open

Ability to access request extensions in Helpers #51

untitaker opened this issue Sep 18, 2016 · 2 comments

Comments

@untitaker
Copy link
Contributor

I want to be able to access the current request (in particular the extensions field) from within the template helpers I registered. The end goal is to make url_for from iron-router available in templates.

I realize that this is extremely hard and I'm not sure if handlebars-iron is even supposed to solve it. Flask solves the general problem by adding threadlocals everywhere, but I don't think that's the way to go for a framework and language where performance, control and data flow is more explicit than elsewhere.

@sunng87
Copy link
Owner

sunng87 commented Sep 18, 2016

Well, the Context object is design to pass data to templates. So I think you can put the request data into context can access it from helper. To make it elegant perhaps we can design an Iron middleware to put some Request data into context.

I have an undocumented project https://github.com/sunng87/handlebars-template-handler you might be interested in.

@untitaker
Copy link
Contributor Author

Would there be a possibility to throw arbitrary types onto Context as well, in
the style of request.extensions? Right now I would need to serialize
data to JSON and back.

Probably would only be usable from helper functions, not directly from the
template.

On Sun, Sep 18, 2016 at 08:24:58AM -0700, Ning Sun wrote:

Well, the Context object is design to pass data to templates. So I think you can put the request data into context can access it from helper. To make it elegant perhaps we can design an Iron middleware to put some Request data into context.

I have an undocumented project https://github.com/sunng87/handlebars-template-handler you might be interested in.

You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#51 (comment)

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