Initial commit for OpenECOMP SDN-C OA&M
[sdnc/oam.git] / dgbuilder / dgeflows / node_modules / ejs / README.md
1 # EJS
2
3 Embedded JavaScript templates
4
5 [![Build Status](https://img.shields.io/travis/mde/ejs/master.svg?style=flat)](https://travis-ci.org/mde/ejs)
6 [![Developing Dependencies](https://img.shields.io/david/dev/mde/ejs.svg?style=flat)](https://david-dm.org/mde/ejs#info=devDependencies)
7
8 ## Installation
9
10 ```bash
11 $ npm install ejs
12 ```
13
14 ## Features
15
16   * Control flow with `<% %>`
17   * Escaped output with `<%= %>`
18   * Unescaped raw output with `<%- %>`
19   * Trim-mode ('newline slurping') with `-%>` ending tag
20   * Custom delimiters (e.g., use '<? ?>' instead of '<% %>')
21   * Includes
22   * Client-side support
23   * Static caching of intermediate JavaScript
24   * Static caching of templates
25   * Complies with the [Express](http://expressjs.com) view system
26
27 ## Example
28
29 ```html
30 <% if (user) { %>
31   <h2><%= user.name %></h2>
32 <% } %>
33 ```
34
35 ## Usage
36
37 ```javascript
38 var template = ejs.compile(str, options);
39 template(data);
40 // => Rendered HTML string
41
42 ejs.render(str, data, options);
43 // => Rendered HTML string
44 ```
45
46 You can also use the shortcut `ejs.render(dataAndOptions);` where you pass
47 everything in a single object. In that case, you'll end up with local variables
48 for all the passed options.
49
50 ## Options
51
52   - `cache`           Compiled functions are cached, requires `filename`
53   - `filename`        Used by `cache` to key caches, and for includes
54   - `context`         Function execution context
55   - `compileDebug`    When `false` no debug instrumentation is compiled
56   - `client`          Returns standalone compiled function
57   - `delimiter`       Character to use with angle brackets for open/close
58   - `debug`           Output generated function body
59   - `_with`           Whether or not to use `with() {}` constructs. If `false` then the locals will be stored in the `locals` object.
60
61 ## Tags
62
63   - `<%`              'Scriptlet' tag, for control-flow, no output
64   - `<%=`             Outputs the value into the template (HTML escaped)
65   - `<%-`             Outputs the unescaped value into the template
66   - `<%#`             Comment tag, no execution, no output
67   - `<%%`             Outputs a literal '<%'
68   - `%>`              Plain ending tag
69   - `-%>`             Trim-mode ('newline slurp') tag, trims following newline
70
71 ## Includes
72
73 Includes are relative to the template with the `include` call. (This
74 requires the 'filename' option.) For example if you have "./views/users.ejs" and
75 "./views/user/show.ejs" you would use `<%- include('user/show'); %>`.
76
77 You'll likely want to use the raw output tag (`<%-`) with your include to avoid
78 double-escaping the HTML output.
79
80 ```html
81 <ul>
82   <% users.forEach(function(user){ %>
83     <%- include('user/show', {user: user}); %>
84   <% }); %>
85 </ul>
86 ```
87
88 Includes are inserted at runtime, so you can use variables for the path in the
89 `include` call (for example `<%- include(somePath); %>`). Variables in your
90 top-level data object are available to all your includes, but local variables
91 need to be passed down.
92
93 NOTE: Include preprocessor directives (`<% include user/show  %>`) are
94 still supported.
95
96 ## Custom delimiters
97
98 Custom delimiters can be applied on a per-template basis, or globally:
99
100 ```javascript
101 var ejs = require('ejs'),
102     users = ['geddy', 'neil', 'alex'];
103
104 // Just one template
105 ejs.render('<?= users.join(" | "); ?>', {users: users}, {delimiter: '?'});
106 // => 'geddy | neil | alex'
107
108 // Or globally
109 ejs.delimiter = '$';
110 ejs.render('<$= users.join(" | "); $>', {users: users});
111 // => 'geddy | neil | alex'
112 ```
113
114 ## Layouts
115
116 EJS does not specifically support blocks, but layouts can be implemented by
117 including headers and footers, like so:
118
119
120 ```html
121 <%- include('header'); -%>
122 <h1>
123   Title
124 </h1>
125 <p>
126   My page
127 </p>
128 <%- include('footer'); -%>
129 ```
130
131 ## Client-side support
132
133 Go to the [Latest Release](https://github.com/mde/ejs/releases/latest), download
134 `./ejs.js` or `./ejs.min.js`.
135
136 Include one of these on your page, and `ejs.render(str)`.
137
138 ## Related projects
139
140 There are a number of implementations of EJS:
141
142  * TJ's implementation, the v1 of this library: https://github.com/tj/ejs
143  * Jupiter Consulting's EJS: http://www.embeddedjs.com/
144  * EJS Embedded JavaScript Framework on Google Code: https://code.google.com/p/embeddedjavascript/
145  * Sam Stephenson's Ruby implementation: https://rubygems.org/gems/ejs
146  * Erubis, an ERB implementation which also runs JavaScript: http://www.kuwata-lab.com/erubis/users-guide.04.html#lang-javascript
147
148 ## License
149
150 Licensed under the Apache License, Version 2.0
151 (<http://www.apache.org/licenses/LICENSE-2.0>)
152
153 - - -
154 EJS Embedded JavaScript templates copyright 2112
155 mde@fleegix.org.
156
157