gpt4 book ai didi

javascript - 如何将 jade 表达式作为 mixin 参数传递?

转载 作者:行者123 更新时间:2023-11-30 08:39:26 26 4
gpt4 key购买 nike

我有一个简单的 jade mixin:

mixin event(title)
.panel.panel-default
.panel-heading !{title}
.panel-body
if block
block
else
p No content provided

我可以这样调用它:

  - var title = "<a href='profile/@Carl'> @Carl</a>"

+event ( title )
| It wasn't that hard. But all in all I'm glad I did it
| because I feel so much better now.
br
| Really. Thank god, it's over

但我想做的是像这样用 Jade 表达标题:

  - var title = a(href='profile/@Carl') @Carl

+event ( title )
| It wasn't that hard. But all in all I'm glad I did it
| because I feel so much better now.
br
| Really. Thank god, it's over

但是jade不喜欢这样,返回错误

SyntaxError: Unexpected character '@' (191:43)

有什么办法可以实现吗?

Note the line 43 mentioned in the error doesn't exist in the file. This is suspicious

最佳答案

this answer中的信息导致了一个对我有用的解决方案......

你可以让你的标题成为mixin,动态调用你的mixin

mixin event(title)
.panel.panel-default
.panel-heading
+#{title}
.panel-body
if block
block
else
p No content provided

mixin title
a(href='profile/@Carl') @Carl

+event("title")
| It wasn't that hard. But all in all I'm glad I did it
| because I feel so much better now.
br
| Really. Thank god, it's over

关于javascript - 如何将 jade 表达式作为 mixin 参数传递?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28034107/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com