Render templates using over-ridable source directories
o = new Templateer('test/templates')
o.addSource('test/overrides')
data = { 'foo': 'bar' }
o.renderFile( 'foo.md', 'output.md', data )
o.renderPath( 'folder', 'output/folder', data )
Render Handlebar templates, allowing for multiple source directories and template over-rides.
addSource( sourcePath )
Add a source directory to use when loading a template. You may call this method multiple times to specify multiple sources. When rendering a template, templateer while search the source directories in reverse order that they were added. This has the affect that templates can be over-ridden.
find( template )
Accepts a template name and returns the full path to a matching template file.
gather( path )
Return all available templates in a given directory relative to any source
renderFile( templatePath, outputPath, data )
Render a single template to an output destination
renderPath( templatePath, outputPath, data )
Render an entire directory and subdirectories to an output destination
findSync( template )
Accepts a template name and returns the full path to a matching template file.
gatherSync( path )
Return all available templates in a given directory relative to any source
renderFileSync( templatePath, outputPath, data )
Render a single template to an output destination
renderPathSync( templatePath, outputPath, data )
Render an entire directory and subdirectories to an output destination
You can set the default source directories for all Templateer
objects by modifying the prototype:
Templateer.prototype.sources = [ 'default/templates' ]
o = new Templateer( 'override/templates' )
Maverik Minett [email protected]
© 2020-2021 Maverik Minett
MIT