lundi 12 octobre 2020

How i use if on ejs with MongoDB?

i want to Show a user how logged in somthing if the MongoDB Boolean=true is.

 <h3>Welcome <span class="red"><%= user.name %> </span> <% if (user.admin === true){ %> <img 
src="/assets/a-card.svg" width="20" height="15"><% } %>to my Webpage</h3>

I get a Error, i check the Internet and they say the same. i Render my EJS:

router.get('/dashboard', ensureAuthenticated, (req, res) =>
    res.render('dashboard', {
        user: req.user
    })
);

i get only error if i add the if else like in the docs from ejs to show/hide element in the Frontend with if else.

Error: Unexpected token 'if'

Aucun commentaire:

Enregistrer un commentaire