Jade include with parameter

≯℡__Kan透↙ 提交于 2021-02-07 11:26:40

问题


In an older version of Jade I was able to include partials and pass variables into them like this: !=partial('partials/video', {title:video.title, artist:video.artist}) now the partial connotation does not exist any more. How do I achieve the same thing using the include connotations?


回答1:


You can use mixins for that. Wrap your include content inside a mixin and call the mixin function in your pug file. See my example below.

include-file.pug

mixin my-include(title, description)
  h1= title
  p= description

index.pug

include include-file
html
  head
  body
    +my-include('my title', 'my description')


来源:https://stackoverflow.com/questions/37936197/jade-include-with-parameter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!