A library that enhances handlebars with better file system support, templates compilation, and partials registration.
dist | ||
test | ||
ts | ||
.gitignore | ||
.npmignore | ||
package.json | ||
README.md |
smarthbs
handlebars with better fs support
Availabililty
Status for master
Usage
Use TypeScript for best in class instellisense.
Note: Why did we decide against a class based architecture?
Easy: handlebars.js is already pretty determined how things are handled internally, namely a global partial template registry It doesn't make sense to then introduce a scoped partial template approach.
import * as smarthbs from 'smarthbs'
// read all .hbs files in a directory and any child directories and use relative path as partial string identifier
smarthbs.registerPartialDir(testPartialDir)
// read all .hbs files in a particular directory and level, output them to a destination and specify a .json file to read any referenced data
smarthbs.compileDirectory(testHbsDir, testResultDir, 'data.json')