Format-Stream
A streaming simple formatter.
API
var format = token stream
format
is a transform stream that checks if each chunk of data matches the
token. If it does not, then the chunk is passed through. Otherwise, format
emits data from the second argument, stream
until it is consumed.
Example
Suppose you have a file called base-template.html
:
"Your app!" {{welcome}}
And one called welcome-template.html
.
<p>"Hey you party people!"</p>
In index.js you write:
var Sentinal = Format = token = '{{welcome}}' var inside_stream = fs outside_stream = fs // Make sure any instance of {{welcome}} is emitted in its// own data eventvar tokenizer = token format = token inside_stream outside_stream
Then node index.js
will print:
<html>
<head>
<title>"Your app!"</title>
</head>
<body>
<p>"Hey you party people!"</p>
</body>
</html>