tj / ejs

Embedded JavaScript templates for node
4.47k stars 513 forks source link

Help! I am Using Vs code and it doesn't recognize ejs tags. #253

Open fatajomustapha10 opened 4 years ago

fatajomustapha10 commented 4 years ago

I am Using Vs code it doesn't recognize ejs tags when they are inside an html tag like the input tag below :

<input type="checkbox" name="checkbox" value="<%=item._id%>" onChange="this.form.submit()"> Before changing the default value property from on to <%=item._id%> it would actually print on, Now it does nothing ! and in the code itself i can see that it doesn't recognize it because the color doesn't change as usual.

Any suggestion is appreciated.

fatajomustapha10 commented 4 years ago

After much trial and error(a day and a half to be precise) I used this <%- instead of <%= and it worked. According to the documentation this <%- tag outputs unescaped value into template. See full code below:

value='<%-item._id%>' <input type="checkbox" name="checkbox" value="<%-item._id%>" onChange="this.form.submit()"> and I have a clue of how that worked but if any one can give me a comprehensive explanation that would be greatly appreciated. I would love to understand completely these how this tag works.