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
- A template repo **must** have a `template` directory that holds the template files.
70
70
71
-
- A template repo **may** have a `meta.json` file that provides metadata for the template. The`meta.json` can contain the following fields:
71
+
- A template repo **may** have a metadata file for the template which can be either a `meta.js` or`meta.json` file. It can contain the following fields:
The `prompts` field in `meta.json` should be an object hash containing prompts for the user. For each entry, the key is the variable name and the value is an [Inquirer.js question object](https://github.com/SBoudrias/Inquirer.js/#question). Example:
81
+
The `prompts` field in the metadata file should be an object hash containing prompts for the user. For each entry, the key is the variable name and the value is an [Inquirer.js question object](https://github.com/SBoudrias/Inquirer.js/#question). Example:
82
82
83
83
```json
84
84
{
@@ -129,9 +129,27 @@ Two commonly used Handlebars helpers, `if_eq` and `unless_eq` are pre-registered
129
129
{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
130
130
```
131
131
132
+
##### Custom Handlebars Helpers
133
+
134
+
You may want to register additional Handlebars helpers using the `helpers` property in the metadata file. The object key is the helper name:
135
+
136
+
```js
137
+
module.exports= {
138
+
helpers: {
139
+
lowercase:str=>str.toLowerCase()
140
+
}
141
+
}
142
+
```
143
+
144
+
Upon registration, they can be used as follows:
145
+
146
+
```handlebars
147
+
{{ lowercase name }}
148
+
```
149
+
132
150
#### File filters
133
151
134
-
The `filters` field in `meta.json` should be an object hash containing file filtering rules. For each entry, the key is a [minimatch glob pattern](https://github.com/isaacs/minimatch) and the value is a JavaScript expression evaluated in the context of prompt answers data. Example:
152
+
The `filters` field in the metadata file should be an object hash containing file filtering rules. For each entry, the key is a [minimatch glob pattern](https://github.com/isaacs/minimatch) and the value is a JavaScript expression evaluated in the context of prompt answers data. Example:
0 commit comments