4 Embedded JavaScript templates.
12 * Complies with the [Express](http://expressjs.com) view system
13 * Static caching of intermediate JavaScript
14 * Unbuffered code for conditionals etc `<% code %>`
15 * Escapes html by default with `<%= code %>`
16 * Unescaped buffering with `<%- code %>`
17 * Supports tag customization
18 * Filter support for designer-friendly templates
24 <h2><%= user.name %></h2>
29 ejs.compile(str, options);
32 ejs.render(str, options);
37 - `locals` Local variables object
38 - `cache` Compiled functions are cached, requires `filename`
39 - `filename` Used by `cache` to key caches
40 - `scope` Function execution context
41 - `debug` Output generated function body
42 - `open` Open tag, defaulting to "<%"
43 - `close` Closing tag, defaulting to "%>"
47 Custom tags can also be applied globally:
49 var ejs = require('ejs');
53 Which would make the following a valid template:
59 EJS conditionally supports the concept of "filters". A "filter chain"
60 is a designer friendly api for manipulating data, without writing JavaScript.
62 Filters can be applied by supplying the _:_ modifier, so for example if we wish to take the array `[{ name: 'tj' }, { name: 'mape' }, { name: 'guillermo' }]` and output a list of names we can do this simply with filters:
66 <p><%=: users | map:'name' | join %></p>
70 <p>Tj, Mape, Guillermo</p>
84 Or perhaps capitalize the first user's name for display:
86 <p><%=: users | first | capitalize %></p>
90 Currently these filters are available:
108 - replace:pattern,substitution
115 ## client-side support
117 include `./ejs.js` or `./ejs.min.js` and `require("ejs").compile(str)`.
123 Copyright (c) 2009-2010 TJ Holowaychuk <tj@vision-media.ca>
125 Permission is hereby granted, free of charge, to any person obtaining
126 a copy of this software and associated documentation files (the
127 'Software'), to deal in the Software without restriction, including
128 without limitation the rights to use, copy, modify, merge, publish,
129 distribute, sublicense, and/or sell copies of the Software, and to
130 permit persons to whom the Software is furnished to do so, subject to
131 the following conditions:
133 The above copyright notice and this permission notice shall be
134 included in all copies or substantial portions of the Software.
136 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
137 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
138 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
139 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
140 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
141 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
142 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.