panda-template

2.0.2 • Public • Published

panda-template

Build Status

Handlebars + Panda Goodies in a quick and easy interface.

import PandaTemplate from "panda-template"
import {read} from "fairmont"
= 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 templatedata

Built 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.

Readme

Keywords

Package Sidebar

Install

npm i panda-template

Weekly Downloads

0

Version

2.0.2

License

ISC

Unpacked Size

15.7 kB

Total Files

4

Last publish

Collaborators

  • dyoder
  • freeformflow