-
Notifications
You must be signed in to change notification settings - Fork 169
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
Is it actually useful for {{helper}} to always be relative to the current directory? #9
Comments
Since webpack/loader-utils#2, it should be possible to use In my opinion, it kind of makes sense for this to be the default, instead of |
I've given up on using this for now. Every time that I try it ends up being a huge unsuccessful time sync for me. |
Agree with this. I just want to put helpers into a folder, and have them globally available in all templates. Making them relative is really bizarre. |
Sorry, it's been a while but didn't I show how this is done in the example?: https://github.com/altano/handlebars-loader/blob/master/example/webpack.config.js Can you see if using the resolve fallback option makes this possible for you, @stevewillard |
Hmm that doesn't seem to help.
And I have a /helpers/bucketPrefix.js
It works if I do $bucketPrefix -- I would really prefer to not do this, because I'm trying to convert a large project to webpack from RequireJS |
Oh right, now I remember, that's why we added the |
Disregard last message, that's what this thread is about. I'll spend some time today catching up but bare with me because I've forgotten all of these discussions :) |
This works as is. "$" causes the item to be loaded as a module (which can make use of webpack resolve options), but you don't have to use it. If you use the helperDirs option, you can use helpers without "$" prefix. If your helper is in a nested subdirectory, there is one caveat: you cannot use forward slashes in Handlebars identifiers, which includes helper names, without escaping them with brackets. You can see in this JSFiddle that it is required with just Handlebars. So the solution is to just put your helper name, when it has nested folders, in angle brackets. I created this example to illustrate how to do it. Please let me know if you can't figure it out. |
I don't see how having view helpers specific to the current directory is realistically helpful in a project. Generally these helper functions are defined globally for all templates with a registerHelper function.
So why not have the default behavior to load from the helperDirs set from the webpack.config loader object instead of needing to prepend
$
?My main issue is that
$
is interfering with handlebars-xgettext (translation extractor) being able to recognize the function as a message function. I want to be able to use this in a way where my templates would look the same as if I were not using this and it doesn't appear to be possible.Perhaps there could be a
searchHelperDirsByDefault
configuration option.The text was updated successfully, but these errors were encountered: