mercredi 22 août 2018

If-else shorthand in ejs template?

Below is the code from EJS file which i am rendering but i am not able figure out the correct syntax for the if statement shorthand.

Here "cchoice" is the object that i am passing while rendering and it is working if i remove the if statement, hence there is no problem in getting its value.

<h1>Welcome,
    <%= cchoice %>
</h1>
<% cchoice =='dog' ? <p>good choice</p> : <p>cool!</p> %>

Suggest the correct syntax for the above shorthand for if statement.

Aucun commentaire:

Enregistrer un commentaire