handlebars-partial-file
v1.0.0
Published
Helper utility for including files as Handlebars template partials
Downloads
3
Readme
Description
Helper utility for including files as Handlebars template partials. handlebars-partial-file reads a file's contents and registers it as a partial for use within a Handlebars template.
Installation
npm install handlebars-partial-file
Usage
Require the package and initialize options:
const hbsPartialFile = require('handlebars-partial-file')(options);
options
{
referenceDir: '.' // Directory path from which to reference the registered partials
}
Register a file as a Handlebars partial
hbsPartialFile.registerFile(filepath, [nameOfPartial]);
argsfilepath
- The file path to include as partial.nameOfPartial
- (Optional) Name to register the partial as. If omitted, the file name will be used.
Register a directory whose files are to be registered as Handlebars partials
hbsPartialFile.registerDirectory(dirPath, ext);
argsdirPath
- Directory path whose files to include.ext
- (Optional) Permitted file extension, or *
. If omitted, all files would be included.