@n7e/templating-handlebars
v0.1.0
Published
A Handlebars template engine implementation.
Maintainers
Readme
Tempalting Handlebars
A Handlebars template engine implementation.
For further insights, read on.
Installation
To install this library use your favorite package manager. No additional steps are required to start using the library.
npm install @n7e/templating-handlebarsThis library is implemented in TypeScript but can be used with JavaScript without any additional steps.
Template Engine
The template engine will locate the template with or without the .hbs file
extension. And render it with the given context.
import handlebars from "handlebars";
import { TemplateEngine } from "@n7e/templating-handlebars";
import { resolve } from "node:path";
const templateDirectories = [
resolve(process.cwd(), "resources/templates"),
resolve(process.cwd(), "some-other/template/directory")
];
const templateEngine = new TemplateEngine(handlebars, templateDirectories);
console.log(await templateEngine.render("some/template", {name: "Martin"}));