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

Accessing View Helpers From Templates #89

Open
Undistraction opened this issue Dec 4, 2013 · 1 comment
Open

Accessing View Helpers From Templates #89

Undistraction opened this issue Dec 4, 2013 · 1 comment
Labels

Comments

@Undistraction
Copy link

It seems that view helpers are not directly available in .hbs.erb templates? Or am I missing something?

I have managed to access them using:

<% environment.context_class.instance_eval { include ExampleHelper } %>

But it would be great if they were available directly.

@AlexRiedler
Copy link
Collaborator

So View Helpers generally access non-constant data, and since handlebar files (.hbs) are in the asset pipeline (can be precompiled etc), they have no concept of a 'view'; as a result they do not include the View Helper.

I am hoping this explains why they are not directly available; and potentially why it does not make sense to add them. I am up for debate over this, just a question of how you would go about choosing the correct helper given a template file name? (edit) Assuming it is possible (end-of-edit).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants