-
Notifications
You must be signed in to change notification settings - Fork 126
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 there anyway to precompile handlebars helpers as well? #8
Comments
I'm not sure I understand what you're asking, but you can control the filepath of your precompiled templates by using the option processName: |
What I mean is if I have a helpers.js file that contains a bunch of calls to Handlebars.registerHelper, I'd be a bonus if the precompilation stage could effectively just concat that right into the precompiled templates. Admittedly, it's not a big deal and I could do it by using a concat task that concatenates my helpers and the precompiled template file myself; so feel free to close the issue if you'd like. |
Ahh, ok. Yes, that's definitely something that should be handled with the concat task |
@avidal I'm running into this issue -- would you mind sharing exactly how you went about adding helpers to your precompiled templates.js? |
@c4urself I didn't add it to the precompiled templates.js, I just created a new helpers.js which I load after I load the runtime and before I load the templates: // helpers.js
(function(Handlebars) {
Handlebars.registerHelper('foo', function() {});
}(window.Handlebars)); |
@avidal Thanks for the reply! I had gotten it working as well -- I was using an older Handlebars version which was causing some errors. |
@avidal I'm not being able to use custom helpers in my precompiled templates. I'm doing as you suggest, first runtime, then helpers, then compiled templates. |
I recently wanted to do this and modified grunt-contrib-handlebars to pre-compile helpers into the same file (commit: andycbriggs@6494373). You pass the helpers to the options hash, here I keep mine in an external file as a node module.
That commit is a quick try and by no means tested for all cases, but would this be something that people would be interested in? |
Any chance for a helpers filepath, which will be mixed in when precompiling?
The text was updated successfully, but these errors were encountered: