simple and fast multi-paradigm streaming templating
Simple and fast multi-paradigm streaming templating.
Plant is a templating 'engine' based around the idea that working with templates should not be a complex task, with templating tools not doing much at all other than filling in the blanks. That's where plant comes in. It just seeds data from an object into an html template with matching keys. Because flexibility is a good thing and streams are a great way to work with IO, plant can be used in both a functional style and as a stream. Check out the examples for more details.
The best way to use plant is to pipe a file stream to it:
Given we're using an
index.html file with the following contents:
var plant =var fs =var data =title: 'streaming plant'header: 'streams are pretty neat'paragraph: 'and plants are nice to eat'var planted =fs
This will send the following to stdout (or whatever writable stream you want to send it to):
streaming plantstreams are pretty neatand plants are nice to eat
If you're dealing with files in a synchronous manner or if you're templating strings, you can use plant like this:
Given we're using an index.html file with the following contents:
var plant =var html = fsvar data =title: 'Synchronous example'header: 'Don\'t use sync'paragraph: 'things to put in the paragraph'var planted =console
Your output will look like this:
Synchronous exampleDon't use syncthings to put in the paragraph
npm install plant