翡翠"属性"不适用于mixin

Ash*_*Ash 1 attributes mixins pug

我在Laravel上使用Jade 1.3.0.我有这个mixin定义:

mixin ShotPreview()
    div(attributes).shot-preview.tile
        each n in [1,2,3]
            div.tile-content
                img(src="/thumbs/{{shot.id}}_#{n}.jpg")
        if(block)
            block
Run Code Online (Sandbox Code Playgroud)

我称之为

+ShotPreview()(data-role="live-tile" data-effect="fade" ng-class="{'selected': shot.selected}" ng-click="shot.selected=!shot.selected").live.double
Run Code Online (Sandbox Code Playgroud)

但是,我的mixin的根div元素被渲染为

<div attributes="attributes" class="shot-preview tile">
Run Code Online (Sandbox Code Playgroud)

我不明白为什么.没有错误,语法看起来没问题.我是Jade的新手,所以我觉得这是傻事,但我真的被卡住了.

tim*_*hew 7

您需要使用新语法,将属性传递给元素

div&attributes(attributes).shot-preview.tile
Run Code Online (Sandbox Code Playgroud)

请参阅此处的讨论:https://github.com/visionmedia/jade/issues/1294

  • 上帝,我刚刚放弃谷歌第7页或者其他什么......谢谢你! (2认同)