Here's a short guide to EJS syntax. For more information, consult the official EJS documentation.
When using EJS templating engine, all variables are available under one top-level variable named it
. For example, to access context
variable listed in the table below, you must write it.context
.
You refer to variables like this:
If the variable is an object with properties of its own, you can refer to them like so:
You can use EJS comments in your files. Commented out sections won't show up in the final rendered output.
Here's an example of if-condition:
This is how you iterate over a collection of items:
If you don't want to process a EJS expression, you can escape it like so: