ejs中<%=,<%和<%-之间的差异 [英] The difference between <%=, <% and <%- in ejs

查看:103
本文介绍了ejs中<%=,<%和<%-之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如我在标题中所写.在Ejs中,<%=<%<%-有什么区别?例如,我看到了此代码<% include ../partials/header.ejs %>,然后有此代码<%= title %>.我还在某处看到了<%-,但是在任何地方都找不到代码示例.那有什么区别呢?我什么时候使用哪个?

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?

我找到了,但这是针对ruby on rails <%%>之间的差异.和<%=%>在RoR中

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

推荐答案

以下内容来自 ejs文档(标记部分):

The following is from ejs docs (tag section):

  • <%'Scriptlet'标签,用于控制流,无输出
  • <%=将值输出到模板中(已转义HTML)
  • <%-将未转义的值输出到模板中
  • <% 'Scriptlet' tag, for control-flow, no output
  • <%= Outputs the value into the template (HTML escaped)
  • <%- Outputs the unescaped value into the template

此处

这篇关于ejs中&lt;%=,&lt;%和&lt;%-之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆