handlebars-dir-render
v1.0.2
Published
Renders a template source directory to a destination directory, with a given context
Downloads
2
Maintainers
Readme
handlebars-dir-render
Given a context and a source directory of handlebars templates, recursively renders all files from source directory to destination directory.
Strips and *.hbs
& *.handlebars
extensions from source directory.
Installation
npm install handlebars-dir-render
Usage
import { render } from 'handlebars-dir-render';
render(srcDir, dstDir, context);
or
const render = require('handlebars-dir-render').render;
render(srcDir, dstDir, context);
API
/**
* Recursively renders template files in srcDir to dstDir.
* Strips any *.hbs and *.handlebars extensions from source files.
* Provides the ability to filter files in source directory.
*
* @param srcDir source directory with template
* @param dstDir destination directory
* @param context The handlerbars context object
* @param filter (optional) function to filter files. Defaults to null - all files are processed.
* signature: ({path: string, stats: fstats}) => boolean
* @param options (optional) { handlebars: anHandlebarsInstance, hb_options: handlebar-options }
*/
async function render (
srcDir: string,
dstDir: string,
context: any,
filter: (File) => boolean = null,
options: Options = null
): Promise<string[]>
License
Apache-2.0
Support
Bugs, PRs, comments, suggestions welcomed!