You can clone with
Would be really handy to compile templates recursively:
handlebars -R templates/ -f templates.js -a -r templates
I am involved in a node module called Handlebar-rider, written originally by @cif, that does this. And it's really not that difficult. I love writing code for it, but if Handlebars natively supported recursive folders and daemonized (ish) folder watching then there would be no competition left.
I am perfectly willing to write the code that makes this happen, as surely many other people are. But I don't want to write it and submit the pull request if there is either a lack of interest or if it won't be accepted. It just seems like such a basic feature that in my thinking there has to be a reason it's not done yet.
@piercemoore if you want to submit a PR I'll work with you to get it in. This seems like a useful feature.
@kpdecker It's a deal. I'm actually pretty excited to get working on it. I have a lot of code on the ground for this other module, but I'll hopefully be able to port it over without too much trouble. The way it works in handlebar-rider is that it traverses the directory structure and creates namespaced templates out of the folder names. So if you had the following directory structure:
Then you could access the compose template by calling Handlebars.templates['messages/compose']. You could also access the labels template by calling Handlebars.templates['messages/elements/labels']. And so on and so forth :-P
Right now we're just including all the existing templates in the Handlebars.partials object as well, which is the easiest way to allow you to access all the templates in Handlebars.partials inside other templates.
I'll get it written and submitted this weekend :D
in fact you can do like this:
handlebars "your folder" > templates.js
and it will precompile all the templates recursively!
@piercemoore I am very very interested in this feature, especially in an AMD usage, have you made any progress on this ? I'm willing to give you a hand if you need some help :)
@victorwpbastos what you are talking about is compiling recursively into a single file, if i understand well the point here is to have a separate output file for each file in the directories, the whole respecting the original directory structure
@feychenie the original question was about precompiling all templates in a folder recursively to a single template file.
Closing this as I think that 17e1b1f resolved this.