docs/api.md
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
### Table of Contents
* [Benchpress][1]
* [registerHelper][2]
* [Parameters][3]
* [setGlobal][4]
* [Parameters][5]
* [flush][6]
* [registerLoader][7]
* [Parameters][8]
* [precompile][9]
* [Parameters][10]
* [compileRender][11]
* [Parameters][12]
* [\__express][13]
* [Parameters][14]
* [compileParse][15]
* [Parameters][16]
* [render][17]
* [Parameters][18]
* [parse][19]
* [Parameters][20]
## Benchpress
### registerHelper
Register a helper function
#### Parameters
* `name` **[string][21]** Helper name
* `fn` **[function][22]** Helper function
### setGlobal
Set a global data value
#### Parameters
* `key` **[string][21]** Property key
* `value` **[Object][23]** Property value
### flush
Clear the template cache
### registerLoader
Register a loader function to fetch templates
* `loader(name, callback) => callback(templateFunction)`
* `loader(name) => Promise<templateFunction>`
#### Parameters
* `loader` **[function][22]**
## precompile
Precompile a benchpress template
* `precompiled(source): Promise<string>`
* `precompile(source, {}, callback) => callback(err, output)`
* `precompile({ source }, callback) => callback(err, output)`
### Parameters
* `source` **[string][21]** Template source
* `options`
* `callback` **[function][22]?** (err, output)
Returns **[Promise][24]<[string][21]>** output code
## compileRender
Compile a template and render it
Automatically caches template function based on hash of input template
### Parameters
* `templateSource` **[string][21]**
* `data` **any**
* `block` **[string][21]?**
Returns **[Promise][24]<[string][21]>** rendered output
## \__express
Provide functionality to act as an express engine
### Parameters
* `filepath` **[string][21]** Compiled template file path
* `data` **[Object][23]** Data with which to parse the template
* `next` **[function][22]** (err, output)
## compileParse
Alias for [compileRender][11], but uses a callback
### Parameters
* `templateSource` **[string][21]**
* `block` **[string][21]?**
* `data` **any**
* `callback` **[function][22]** (err, output)
**Meta**
* **deprecated**: Use [compileRender][11] instead
## render
Fetch and run the given template
### Parameters
* `template` **[string][21]** Name of template to fetch
* `data` **[Object][23]** Data with which to run the template
* `block` **[string][21]?** Parse only this block in the template
Returns **[Promise][24]<[string][21]>** Rendered output
## parse
Alias for [render][17], but uses a callback
### Parameters
* `template` **[string][21]** Name of template to fetch
* `block` **[string][21]?** Render only this block in the template
* `data` **[Object][23]** Data with which to run the template
* `callback` **[function][22]** callback(output)
**Meta**
* **deprecated**: Use [render][17] instead
[1]: #benchpress
[2]: #registerhelper
[3]: #parameters
[4]: #setglobal
[5]: #parameters-1
[6]: #flush
[7]: #registerloader
[8]: #parameters-2
[9]: #precompile
[10]: #parameters-3
[11]: #compilerender
[12]: #parameters-4
[13]: #__express
[14]: #parameters-5
[15]: #compileparse
[16]: #parameters-6
[17]: #render
[18]: #parameters-7
[19]: #parse
[20]: #parameters-8
[21]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[22]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
[23]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[24]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise