mustache-stream
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
License
MIT