与 Jade 的动态链接
在我的应用程序中使用 Jade + Express + Node.js + Mongoose + MongoDB,但我遇到的这个问题很可能是在 Jade 中:
我有一些代码如下,可以按标题、作者打印帖子列表
div#articles
-each post in records
div.article
#{post.title} was written by #{post.author}
<a href ="#{post.title}"> Link to Article </a>
现在我想要链接编写 Jade 而不是 HTML,但是当我用
a(href='#{post.title}')
它替换该行时,它会链接到 /#{post.title} 而不是变量名称,例如 /newpost1。这样做
a(href=#{post.title})
会返回错误。我确信这是一个语法问题,但我在 GitHub 文档中找不到解决方案
Using Jade + Express + Node.js + Mongoose + MongoDB for my app, but this issue I ran into is likely in Jade:
I have some code as follows that prints a list of posts by title, author
div#articles
-each post in records
div.article
#{post.title} was written by #{post.author}
<a href ="#{post.title}"> Link to Article </a>
Now I want to the link in written Jade instead of HTML, but when I replace the line with
a(href='#{post.title}')
it links to /#{post.title} instead of the variable name such as /newpost1. Doing it as
a(href=#{post.title})
returns an error. I'm sure this is a syntax issue, but I can't find the solution in the GitHub documentation
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
很确定你可以这样做:
pretty sure you can just do:
玉:
html:
jade:
html: