@dotlabel/temple v1.3.0
Temple
Super simple utility to scaffold templated files
Example
temple render readme.hjs > README.mdTemple will pull templates from its storage and use data from your package.json to output a rendered file.
Installation
npm i -g @dotlabel/temple## Usage
Temple is self-documenting as much as possible, use --help to get additional information about Temple and each command.
temple --help
temple render --helpTemple needs only a couple of things to work
- A template engine specification
- Some templates
Specifying and installing templating engines
Temple uses consolidate to render templates and will not install engines unless instructed to do so.
A template engine specification consists of three fields that you need to consider:
{
"name": "hogan",
"module": "hogan.js",
"extensions": [
"hjs",
"hogan"
]
}namethe identifier shared with consolidatemodulethe module name to install from npm when requiredextensionsTemple will attempt to match template file extensions to those listed by the engine specification i.e.readme.hjswould imply usinghoganto render the template.
The easiest way to register a template is to stream in a specification
echo '{"module":"hogan.js","extensions":["hjs"]}' | temple engine hoganThere are a few other options, see temple engine --help.
Once the specification is loaded then you’re free to install it, although Temple will prompt you if you forget this step and try to use a template file requiring the engine.
temple engine --install hoganSpecifying a template file
Easiest way is to stream the template file in.
echo '# {{ name }}' | temple register readme.hjsSee temple register --help
Rendering a template file
Once you have a few templates and at least one engine registered with Temple you’re set to get going
temple render readme.hjs > README.mdIn these examples we have registered hogan as a templating engine and added a readme.hjs template file, when we attempt to render it Temple checks the extensions, finds that it matches hogan and uses hogan.js to render the template to stdout, additionally prompting to install hogan.js if necessary.
License
MIT