简体   繁体   中英

Inheriting attributes in Jade mixins

Is it possible to have a Jade mixin call pass through the attributes passed to the current mixin? Example:

mixin A()
    A=attributes.x

mixin B()
    +A
    B=attributes.x

+B()(x="test")

It outputs:

<A></A>
<B>test</B>

Because the attribute x doesn't get passed through to A . This is desired in most cases. But in my case, I would like to pass through any attributes passed to B into A , without having to list them a priori (ie +A()(x=attributes.x) .

Is this possible?

This question is similar to Passing attributes in a jade mixin But the answer posted there does not work as far as I can tell.

In case someone else stumbles upon this, Forbes Lindesay from the Jade Google group answered the question. It can be done this way:

mixin A()
  | #{attributes.x}

mixin B()
  +A()&attributes(attributes)

+B()(x=“x”)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM