This package has been deprecated

Author message:

Development of this module has been stopped.

mustache-stream

1.1.0 • Public • Published

mustache-stream Build Status js-standard-style

Mustache template renderer for streaming JavaScript objects.

Installation

$ npm install mustache-stream

Test:

$ npm test

API

mustacheStream(template, [options])

  • template

Can be either a string or a function, if it's a function this will be called each time; thus providing the ability to dynamically load templates which is useful for testing.

  • options

An optional object with the following options: transform, prepend, append.

  • transform

A function that supplies the current object in the stream which can be modified synchronously. Also the $index key (the nth object in the stream) is provided.

  • prepend

A string value which will be added to the beginning of the (whole) stream.

  • append

A string value added to the end of the stream.

Mustache templates options and logic are exactly as in the Mustache module.

Example

See test.js and template.mustache for details.

// assume object stream is here
.pipe(mustacheStream(template, {
  transform: function (values) {
    values.$index++
    values.accessDate = new Date().toString()
    return values
  },
  prepend: '<html><body style="font-family: sans-serif"><h1>Repos</h1><ul>',
  append: '</ul><p><b>License:</b> MIT</p></body></html>'
}))

License

MIT

Package Sidebar

Install

npm i mustache-stream

Weekly Downloads

0

Version

1.1.0

License

MIT

Last publish

Collaborators

  • roryrjb