Using waterpipe - misonou/waterpipe GitHub Wiki
The library is a UMD-module that support browsers, AMD and Node.js.
For simplest case in HTML, include using <script> tags:
<script type="text/javascript" src="waterpipe.js"></script>For Node.js, use require():
var waterpipe = require('waterpipe');For ES module, use import:
import waterpipe from 'waterpipe';Returns string with every expression inside {{ }} get interpolated:
waterpipe('The value is {{value}}.', { value: 1 }); // returns the string "The value is 1."Returns values evaluated from the given expression:
waterpipe.eval('value + 1', { value: 1 }); // returns the number 2An additional object with the following options can be passed as the 3rd argument.
Defines global variables readable in this evaluation.
Variables declared here will override those in waterpipe.globals.
Sets indentation of resulting HTML markup.
Each level of nested elements will be indented by the specfied number of spaces or the specific sequence of characters.
If either 0 or an empty string is specified, indentation is turned off as if this option is absent.
Number of spaces or the specific sequence of characters that will be left padded to each line.
This option is only effective if the indent option is present and not equal to 0 or an empty string.
Special HTML characters are not encoded, including ', ", &, < and >, while whitespaces between text, expressions and flow control tags are collapsed. Default is false. See Output control.
Special HTML characters are encoded, including ', ", &, < and >, while whitespaces between text, expressions and flow control tags are collapsed. Default is true. When set to false, noEncode is automatically set to true. See Output control.