EJS
LINKS
EJS.co
Options
cache
Compiled functions are cached, requiresfilename
filename
Used bycache
to key caches, and for includesroot
Set project root for includes with an absolute path (e.g, /file.ejs). Can be array to try to resolve include from multiple directories.views
An array of paths to use when resolving includes with relative paths.context
Function execution contextcompileDebug
Whenfalse
no debug instrumentation is compiledclient
Returns standalone compiled functiondelimiter
openDelimiter
closeDelimiter
‘/li>debug
Outputs generated function bodystrict
When set totrue
, generated function is in strict mode_with
Whether or not to usewith()
{} constructs. Iffalse
then the locals will be stored in the locals object. (Implies--strict
)localsName
Name to use for the object storing local variables when not usingwith
Defaults tolocals
rmWhitespace
Remove all safe-to-remove whitespace, including leading and trailing whitespace. It also enables a safer version of-%>
line slurping for all scriptlet tags (it does not strip new lines of tags in the middle of a line.escape
The escaping function used with<%=
construct. It is used in rendering and is .toString()ed in the generation of client functions. (By default escapes XML).outputFunctionName
Set to a string (e.g., ‘echo’ or ‘print’) for a function to print output inside scriptlet tags.async
When true, EJS will use an async function for rendering. (Depends on async/await support in the JS runtime.
TAGS
<%
‘Scriptlet’ tag, for control-flow, no output<%_
‘Whitespace Slurping’ Scriptlet tag, strips all whitespace before it<%=
Outputs the value into the template (HTML escaped)<%-
Outputs the unescaped value into the template<%#
Comment tag, no execution, no output<%%
Outputs a literal ‘<%’%>
Plain ending tag-%>
Trim-mode (‘newline slurp’) tag, trims following newline_%>
‘Whitespace Slurping’ ending tag, removes all whitespace after it