This second pattern based task allows the use of a pattern for filenames
to parse, also added grunt.template.process calls to allow the use of
package.json values (or any other underscore code) to dynamically create
paths if desired. More details in the comments in the file.
Basically it is intended for environments where you have a one to one data file to base template pairing over multiple files which match a pattern. In the case where I'm using it, the files are organized this way:
app/index.hbr
app/hbr-context/index.json
... etc
So I can add the task 'grunt-compile-handlebars-pattern' to grunt with the following config:
development:{
files: 'app//.hbr',
data: 'hbr-context/.json',
replaceDir:'app/',
withDir:'dist/'
}
This will find all .hbr files in my app folder, look for a .json file under the relative hbr-context folder with the same name, and render an html file with the same name into the 'dist/' folder.
This second pattern based task allows the use of a pattern for filenames to parse, also added grunt.template.process calls to allow the use of package.json values (or any other underscore code) to dynamically create paths if desired. More details in the comments in the file.
Basically it is intended for environments where you have a one to one data file to base template pairing over multiple files which match a pattern. In the case where I'm using it, the files are organized this way:
app/index.hbr app/hbr-context/index.json ... etc
So I can add the task 'grunt-compile-handlebars-pattern' to grunt with the following config: development:{ files: 'app//.hbr', data: 'hbr-context/.json', replaceDir:'app/', withDir:'dist/' }
This will find all .hbr files in my app folder, look for a .json file under the relative hbr-context folder with the same name, and render an html file with the same name into the 'dist/' folder.
Let me know what you think :)