npm install @tiveor/scg
const { StringHelper } = require('@tiveor/scg');
const replaced = StringHelper.replace('This is a {{test}}', '{{test}}', 'joke');
// replaced = "This is a joke"
const { TemplateBuilder, TEMPLATE_HANDLERS } = require('@tiveor/scg');
const ejsBuilder = new TemplateBuilder(TEMPLATE_HANDLERS.EJS);
ejsBuilder
.render('This is a <%= test %>', {
test: 'joke'
})
.then((replaced) => {
// replaced = "This is a joke"
});
const pugBuilder = new TemplateBuilder(TEMPLATE_HANDLERS.PUG);
pugBuilder
.render('This is a #{test}', {
test: 'joke'
})
.then((replaced) => {
// replaced = "This is a joke"
});
const handlebarsBuilder = new TemplateBuilder(TEMPLATE_HANDLERS.HANDLEBARS);
handlebarsBuilder
.render('This is a {{test}}', {
test: 'joke'
})
.then((replaced) => {
// replaced = "This is a joke"
});
node example/index.js
For more information about templates visit the official documentation for each one: