admin管理员组文章数量:1431502
Is it possible to pass in parameter for include
ed pug files inside the parent pug file. For example if I have a child template example.pug
:
p #{name}'s Pug source code!
And a parent parent.pug
h1
| Hello world
include example.pug
It would be nice to do something like
h1
| Hello world
include example.pug {name1}
include exmaple.pug {name2}
What is the way to do this?
Is it possible to pass in parameter for include
ed pug files inside the parent pug file. For example if I have a child template example.pug
:
p #{name}'s Pug source code!
And a parent parent.pug
h1
| Hello world
include example.pug
It would be nice to do something like
h1
| Hello world
include example.pug {name1}
include exmaple.pug {name2}
What is the way to do this?
Share Improve this question asked Apr 17, 2018 at 17:53 xiaolingxiaoxiaolingxiao 4,8956 gold badges44 silver badges91 bronze badges 01 Answer
Reset to default 6You can rewrite your include as a mixin, which accepts parameters.
mixins.pug
mixin person(name)
p #{name}'s Pug source code!
parent.pug
include mixins.pug
h1 Hello world
+person('Kay')
+person('Jamal')
See the pug documentation for more info.
本文标签: javascriptPassing in parameters for pug templates inside pug fileStack Overflow
版权声明:本文标题:javascript - Passing in parameters for pug templates inside pug file - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745465211a2659502.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论