Skip to content

Commit c24cead

Browse files
authored
Add docs for template options (#156)
This adds some docs for the template options, both global and local
1 parent ebb6112 commit c24cead

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ Create isolated engine instances with their own cache system and handlebars engi
185185
var instance1 = hbs.create();
186186
var instance2 = hbs.create();
187187

188+
## Template options
189+
190+
The main use case for template options is setting the handlebars "data" object - this creates global template variables accessible with an `@` prefix.
191+
192+
Template options can be set in 3 ways. When setting global template options they can be [passed as config on creation of an instance](https://github.com/barc/express-hbs#usage), and they can also be updated used the `updateTemplateOptions(templateOptions)` method of an instance. To set template options for an individual request they can be set on `res.locals` using the helper method `updateLocalTemplateOptions(locals, templateOptions)`.
193+
194+
Both of these methods have a companion method `getTemplateOptions()` and `getLocalTemplateOptions(locals)`, which should be used when extending or merging the current options.
195+
188196
## Example
189197

190198
in File `app.js`

0 commit comments

Comments
 (0)