rosid-handler-sightly
A function that loads an Sightly file and transforms it to HTML.
Install
npm install rosid-handler-sightly
Usage
API
const handler = const str = await
Rosid
Add the following object to your rosidfile.js
or routes array. rosid-handler-sightly
will transform all matching HTL files in your source folder to HTML.
<!-- index.html / index.htl -->Hello ${'World'}
<!-- index.html (output) -->Hello World
Parameters
filePath
{String}
Path to file.opts
{?Object}
Options.optimize
{?Boolean}
- Optimize output. Defaults tofalse
.data
{?Object|String}
- Data used to render the template. Defaults to{}
.localOverwrites
{?Boolean}
- Enable or disable custom data per file. Defaults totrue
.
Returns
{Promise<String|Buffer>}
The transformed file content.
Miscellaneous
Data
The data in opts.data
will be used to render your template. opts.data
can either be an object (the data) or a string (path to data file). rosid-handler-sightly
tries to require the path when a string is specified instead of an object. The path must be absolute or relative to the current working directory.
Custom data per file
Create a file with the name filename.data.json
or filename.data.js
along your filename.htl
to add or overwrite data from opts.data
. You can disable this behaviour with the localOverwrites
option.
Environment
rosid-handler-sightly
passes a variable called environment
to your template. environment
is prod
when opts.optimize
is true
and dev
when opts.optimize
is false
.