Converts hbs to htl (sightly)
npm install hbs2htl``sh`
npm install --save hbs2htl
`js`
const Hbs2htl = require('hbs2htl');
`js
const hbs2htl = new Hbs2htl(
, {
template: 'mySightlyTemplate'
});
console.log(hbs2htl.html); // Compatible HTL template
/**
* Output:
*
*
*
*
* ${data.prop}
*
*
*
*/
`Compiling unknown expressions
You can write your own transformations to compile unkown expressions. This is useful if you are using custom helpers.
Handlebars:
`hbs
{{#eachCustom this}}
{{this}}
{{/eachCustom}}
`Default output:
`html
${data}
`To transform this you can use
transform function.`js
console.log((new Hbs2htl(hbsText, {
transform({ tag, props, event }) {
if (event === 'onopentag') {
return '...';
}
if (event === 'onclosetag') {
return '';
}
}
})).html);
``Transform function is called only for unknown handlebar expressions.
This package is still in a very early stage and is extremely buggy. Don't use this package in production yet. Your contributions are welcome! Help us improve this project.