【问题标题】:Jade include with parameter翡翠包带参数
【发布时间】:2016-06-21 05:24:17
【问题描述】:

在旧版本的 Jade 中,我能够像这样包含部分并将变量传递给它们: !=partial('partials/video', {title:video.title, artist:video.artist}) 现在部分内涵已经不存在了。如何使用包含内涵实现相同的目标?

【问题讨论】:

    标签: pug partial


    【解决方案1】:

    您可以为此使用mixins。将包含内容包装在 mixin 中,并在 pug 文件中调用 mixin 函数。请参阅下面的示例。

    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')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-23
      • 2010-10-05
      • 1970-01-01
      相关资源
      最近更新 更多