EJS:<%=与<%- [英] EJS: <%= versus <%-

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

问题描述

我将EJS与正在构建的Node.js Web服务器一起使用。我看到许多EJS示例在输出HTML或字符串时有时使用<%= ,而其他示例(有时在同一模板中)使用< %-

I'm using EJS with a Node.js web server I'm building. I see many EJS examples that sometimes use <%= when outputting HTML or strings, while other examples (sometimes within the same template) use <%-.

我尝试引用 EJS 文档和入门指南,但都给出了没有有关<%-表示法的信息。另外,我的Google搜索尝试没有任何用处。谢谢!

I tried to reference the EJS docs and getting started guide, but both gave no info about the <%- notation. Also, my Google search attempts yielded nothing useful. Thanks!

推荐答案

您可能在Node中使用的EJS版本与您在Google代码中看到的版本不同;在Node版本中,<%= 使HTML转义进入缓冲区,而<%-不会。

The version of EJS you're likely using in Node is not the same as the version you see on Google code; in the Node version, <%= escapes the HTML going into the buffer, while <%- does not. source

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

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