Closed CheyenneForbes closed 2 years ago
EJS does nothing but render whatever data it's given. This is the sort of thing you should be doing in your data processing. A simple take at an implementation would look something like this:
if (typeof someValue == 'undefined') {
someValue = '<%= (someValue) %>';
}
EJS will then render that literal value. If you need to do something like this inside EJS, then you can use %%
for a literal percent.
In the case of development (especially team based), the ability to display the EJS tags when values are undefined can be a bonus. As an example, when work is being done simultaneously with a frontend and backend team or a case where the backend cant be disclosed to the frontend developer for various reasons, being able to display the actual EJS tags when "pulling the values" failed can ease the stress. These values are normally defined in the technical specifications of a project.
code:
parent.parent.list
defined:parent
orparent.parent
orparent.parent.list
undefined:i.name
is also undefined