Skip to content

Commit

Permalink
Merge pull request #508 from zjopy/patch-1
Browse files Browse the repository at this point in the history
fix(docs): missing doc for open and close delimiters
  • Loading branch information
mde authored Apr 21, 2020
2 parents bdbdff4 + 5de0812 commit 40daa57
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $ npm install ejs
* Unescaped raw output with `<%- %>`
* Newline-trim mode ('newline slurping') with `-%>` ending tag
* Whitespace-trim mode (slurp all whitespace) for control flow with `<%_ _%>`
* Custom delimiters (e.g., use `<? ?>` instead of `<% %>`)
* Custom delimiters (e.g. `[? ?]` instead of `<% %>`)
* Includes
* Client-side support
* Static caching of intermediate JavaScript
Expand Down Expand Up @@ -69,7 +69,9 @@ Therefore, we do not recommend using this shortcut.
- `client` When `true`, compiles a function that can be rendered
in the browser without needing to load the EJS Runtime
([ejs.min.js](https://github.com/mde/ejs/releases/latest)).
- `delimiter` Character to use with angle brackets for open/close
- `delimiter` Character to use for inner delimiter, by default '%'
- `openDelimiter` Character to use for opening delimiter, by default '<'
- `closeDelimiter` Character to use for closing delimiter, by default '>'
- `debug` Output generated function body
- `strict` When set to `true`, generated function is in strict mode
- `_with` Whether or not to use `with() {}` constructs. If `false`
Expand Down Expand Up @@ -150,13 +152,15 @@ let ejs = require('ejs'),
users = ['geddy', 'neil', 'alex'];

// Just one template
ejs.render('<?= users.join(" | "); ?>', {users: users}, {delimiter: '?'});
// => 'geddy | neil | alex'
ejs.render('<p>[?= users.join(" | "); ?]</p>', {users: users}, {delimiter: '?', openDelimiter: '[', closeDelimiter: ']'});
// => '<p>geddy | neil | alex</p>'

// Or globally
ejs.delimiter = '$';
ejs.render('<$= users.join(" | "); $>', {users: users});
// => 'geddy | neil | alex'
ejs.delimiter = '?';
ejs.openDelimiter = '[';
ejs.closeDelimiter = ']';
ejs.render('<p>[?= users.join(" | "); ?]</p>', {users: users});
// => '<p>geddy | neil | alex</p>'
```

## Caching
Expand Down

0 comments on commit 40daa57

Please sign in to comment.