2.0.2 • Published 6 years ago
panda-template-esm v2.0.2
panda-template
Handlebars + Panda Goodies in a quick and easy interface.
import PandaTemplate from "panda-template"
import {read} from "fairmont"
T = new PandaTemplate()
do ->
template = await read "template.md"
data = await read "data.yaml"
T.registerPartial "section1", await read "section1.md"
T.registerPartial "section2", await read "section2.md"
T.render template, dataBuilt on Handlebars.
In addition, we include the following helpers:
values: return the values of an object.filter <property> <value>: selects objects whose<property>is the given<value>.pluck <property>: maps an array of objects into an array of values using the given<property>.join <delimiter>: converts an array to a string using the given<delimiter>.sprintf <format> <string>: formats the<string>using the printf-style<format>string.hang <indent> <width> <string>: Format<string>with a hanging indent of<indent>spaces and line<width>.json <value>: serialize into JSON.
API
render
template, context => rendered template
Outputs a rendered template using Handlebars compile.
registerPartial
name, template => null
PandaTemplate associates the Handlebars library as an instance variable when you construct a new PandaTemplate class. This registers a template partial, at the given name, with that Handlebars instance.
handlebars
null => instance of Handlebars
PandaTemplate associates the Handlebars library as an instance variable when you construct a new PandaTemplate class. This exposes that instance for more developer flexibility.