javascript - 嵌套的 EJS 标签。不工作

标签 javascript node.js web ejs

只是一个简单的问题,但我在谷歌上找不到任何内容。

原来是这样

为什么这不起作用?

在第一行,最后的'%>'变成白色enter image description here

这是来 self 的 NodeJS js 文件。当我呈现“loginuserprofile”时,我将 userProfile 变量传递给了 EJS This is from my NodeJS js file 我会得到一个错误

错误:找不到“<%”的匹配结束标记。

我不能使用嵌套 <% %> 吗?

谢谢!

最佳答案

不,你不能使用嵌套 <% %>

您只需要使用 <% if (userProfile.facebook.length === 0) { %>

喜欢

<% if (userProfile.facebook.length === 0) { %>
    <h1>No Facebook!</h1>
<% } %>

关于javascript - 嵌套的 EJS 标签。不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40210362/

相关文章:

javascript - 如何使用 Javascript 和 Ajax 更改 div 背景颜色?

javascript - Jquery 操作 Json 字符串

node.js - 错误: DPI-1047: Cannot locate a 64-bit Oracle Client library in NodeJS

javascript - 使用 Supertest 测试 Express 应用程序时,对第三方库的构造函数进行 stub

java - Spring 启动 WebClient : Closes connection prematurely before response

security - 为什么将 CSRF 预防 token 放在 cookie 中很常见?

html - 内部重定向站点的最佳解决方案

javascript - jQuery "chosen": conflict with 'selected' attribute in option tag

javascript - 使用 Gulp 为所有 .html 页面生成关键 CSS

javascript - 渲染从 props 接收到的 Canvas 对象