The difference between <%=, <% and <%- in ejs [duplicate]

点点圈 提交于 2020-01-12 10:11:09

问题


As I wrote in the title. In Ejs what's the difference between <%=, <% and <%-? for example I saw this code <% include ../partials/header.ejs %>, and then there is this code <%= title %>. I also saw <%- somewhere but cannot find a code example anywhere. So what's the difference? When do I use which?

I found this but it's for ruby on rails Difference between <% %> and <%= %> in RoR


回答1:


The following is from ejs docs (tag section):

  • <% 'Scriptlet' tag, for control-flow, no output
  • <%= Outputs the value into the template (HTML escaped)
  • <%- Outputs the unescaped value into the template

See the difference between escaped and unescaped html here



来源:https://stackoverflow.com/questions/48522768/the-difference-between-and-in-ejs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!