1.0.0 • Published 6 years ago

handlebars-partial-file v1.0.0

Weekly downloads
60
License
ISC
Repository
github
Last release
6 years ago

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]);

args
filepath - 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);

args
dirPath - Directory path whose files to include.
ext - (Optional) Permitted file extension, or *. If omitted, all files would be included.