servebar is a server of static files with support for Handlebars templates.
All files with the .hbs
extension are served as static HTML using Handlebars. All other files are served as-is.
To install servebar, run the following command:
npm install -g servebar
Run the following command in the directory you want to serve:
servebar
Running servebar
in a directory will serve the files in that directory, without further modification. Handlebars templates are rendered, and partials are included from the partials
directory, but all variables are empty, and no helpers are included.
To customize the behavior of servebar
, you can create a servebar
directory in the directory you want to serve. In this directory, you can create the following files:
data.json
: A JSON file with the data to be used in the Handlebars templates.*.js
: Any JavaScript file that exports a function is mounted as a Handlebars helper. The name of the function is used as the name of the helper.
{
"title": "My Website",
"description": "This is my website."
}
const translate = (key) => {
return `translate("${key}")`;
};
module.exports = translate;