You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+50Lines changed: 50 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,10 +93,60 @@ Heres a few of the ways you can use it
93
93
}
94
94
```
95
95
96
+
The available configuration options are as follows
97
+
98
+
Unless otherwise noted, all configurable values can be represented as
99
+
* a string representing the path to a specific file
100
+
* a string representing the path to a [globbed representation](http://gruntjs.com/api/grunt.file#globbing-patterns) of the files, matched up against the values resolved from the `template` configuration
101
+
* an array of literal paths, globbed paths, or a combination of the two
102
+
103
+
__`template`__ - The template fed to handlebars. In addition to the normal configurable values, it can also be an inline string representation of a template (e.g. raw html and handlebars).
104
+
105
+
__`preHTML`__ - Static text to be inserted before the compiled template
106
+
__`postHTML`__ - Static text to be inserted after the compiled template
107
+
108
+
__`templateData` ~~ The data being fed to compiled template, in addition to the normal configurable values, this can be
109
+
* an inline string representation of a data (I don't know why you would do that though, when you can do...)
110
+
* an inline JSON representation of a data
111
+
112
+
__`output`__ - the file(s) that handlebars saves the files to. This can be
113
+
__`globals`__ - globals that can be included, useful for when you have template specific data, but want some data available to all templates
114
+
__`helpers`__ - handlebars helpers
115
+
__`partials`__ - handlebars partials
116
+
117
+
__`registerFullPath`__ - normally, helpers and partials are registered under their basename, rather than their path (e.g. partial at `partials/deep/awesomePartial.handlebars` is registered as `{{> awesomePartial}}`). When set to `true`, helpers and partials are registered under their full paths (e.g. {{> partials/deep/awesomePartial}}), to prevent clobbering after resolving globbed values.
118
+
119
+
120
+
#### A note on globing
121
+
122
+
When you specify templates using globs, the values from `template` are used to create the values for output, for example, if your file structure looks like this
123
+
124
+
```
125
+
|-foo
126
+
|-bar.handlebars
127
+
|-baz.handlebars
128
+
|-bar.json
129
+
|-baz.json
130
+
```
131
+
132
+
and your configuration looks like this
133
+
134
+
```JSON
135
+
{
136
+
"template": "./foo/*.handlebars",
137
+
"templateData": "./foo/*.json",
138
+
"output": "./foo/*.html"
139
+
}
140
+
```
141
+
142
+
the output would be `./foo/bar.html` and `./foo/baz.html`
143
+
144
+
96
145
### Why
97
146
I had to work with several hundred repeated data structures that never changed. Keeping them all in html was silly, but pushing out a template engine for the end user to compile the same information multiple times was even sillier. This allows you to have your templated cake and eat it too.
Copy file name to clipboardExpand all lines: test/compile_handlebars_test.js
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -107,6 +107,16 @@ exports.clean = {
107
107
108
108
test.equal(actual,expected,'Use specific templateName.json per templateName.handlebars (as in globbedTemplateAndOutput) plus multiple global json on top');
0 commit comments