在 pug 文件内传递 pug 模板的参数

chi*_*ro2 5 html javascript pug

include是否可以在父 pug 文件内传递 ed pug 文件的参数。例如,如果我有一个子模板example.pug

p #{name}'s Pug source code!
Run Code Online (Sandbox Code Playgroud)

还有一位家长parent.pug

h1
| Hello world
include example.pug
Run Code Online (Sandbox Code Playgroud)

做类似的事情会很好

h1
| Hello world
include example.pug {name1}
include exmaple.pug {name2}
Run Code Online (Sandbox Code Playgroud)

有什么方法可以做到这一点?

Sea*_*ean 6

您可以将 include 重写为 mixin,它接受参数。

mixins.pug

mixin person(name)
  p #{name}'s Pug source code!
Run Code Online (Sandbox Code Playgroud)

父母.哈巴狗

include mixins.pug

h1 Hello world

+person('Kay')
+person('Jamal')
Run Code Online (Sandbox Code Playgroud)

请参阅哈巴狗文档以获取更多信息。