@@ -102,18 +102,30 @@ const scaffold = SimpleScaffold({
102102 locals: {
103103 property: " value" ,
104104 },
105+ helpers: {
106+ twice : (text ) => [text , text ].join (" " )
107+ }
105108})
106109```
107110
108- The exception in the config is that ` output ` , when used in Node directly, may also be passed a
109- function for each input file to output into a dynamic path:
111+ ### Additional Node.js options
110112
111- ``` typescript
112- config .output = (fullPath , baseDir , baseName ) => {
113- console .log ({ fullPath , baseDir , baseName })
114- return path .resolve (baseDir , baseName )
115- }
116- ```
113+ In addition to all the options available in the command line, there are some JS-specific options
114+ available:
115+
116+ 1 . When ` output ` is used in Node directly, it may also be passed a function for each input file to
117+ output into a dynamic path:
118+
119+ ``` typescript
120+ config .output = (fullPath , baseDir , baseName ) => {
121+ console .log ({ fullPath , baseDir , baseName })
122+ return path .resolve (baseDir , baseName )
123+ }
124+ ```
125+
126+ 2. You may add custom ` helpers ` to your scaffolds . Helpers are simple ` (string) => string ` functions
127+ that transform your ` data ` variables into other values . See [Helpers ](#helpers ) for the list of
128+ default helpers , or add your own to be loaded into the template parser .
117129
118130## Preparing files
119131
@@ -156,9 +168,21 @@ Here are the built-in helpers available for use:
156168| kebabCase | ` {{ kebabCase name }} ` | my - name |
157169| hyphenCase | ` {{ hyphenCase name }} ` | my - name |
158170| pascalCase | ` {{ pascalCase name }} ` | MyName |
171+ | upperCase | ` {{ upperCase name }} ` | MYNAME |
172+ | lowerCase | ` {{ lowerCase name }} ` | myname |
159173
160174> These helpers are available for any data property , not exclusive to ` name ` .
161175
176+ You may also add your own custom helpers using the ` helpers ` options when using the JS API (rather
177+ than the CLI ). The ` helpers ` option takes an object whose keys are helper names , and values are
178+ the transformation functions . For example , ` upperCase ` is implemented like so :
179+
180+ ` ` ` typescript
181+ config.helpers = {
182+ upperCase: (text) => text.toUpperCase(),
183+ }
184+ ` ` `
185+
162186## Examples
163187
164188### Command Example
0 commit comments