如何将 HTML 元素作为参数传递给 pug mixin

问题描述 投票:0回答:1

我想将 HTML 传递到我的 mixin。

类似这样的:

mixin complexElement
    .container
        block header
        block content
        p This is some other content in the container.
        block footer

+complexElement
    block header
        h1 This is the Header
    block content
        p This is the main content.
    block footer
        p This is the footer.

有什么想法吗?

pug
1个回答
0
投票

Mixin 不支持多个命名块。它们仅支持单个未命名块:https://pugjs.org/language/mixins.html#mixin-blocks

您可以嵌套 mixin,并为容器、页眉、内容和页脚分别创建一个 mixin。或者,如果数据足够统一,您可以将其全部作为一个对象传递给一个 mixin。

© www.soinside.com 2019 - 2024. All rights reserved.