javascript - Passing in parameters for pug templates inside pug file - Stack Overflow

Is it possible to pass in parameter for includeed pug files inside the parent pug file. For example if

Is it possible to pass in parameter for includeed 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 includeed 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 0
Add a ment  | 

1 Answer 1

Reset to default 6

You 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745465212a4628886.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信