JADE:无法使用数组生成mixin

时间:2016-10-31 19:15:49

标签: node.js pug

我尝试从使用数组的mixin生成代码:

- var tabList = [
    {
        data: "data-toggle",
        href: "#pp",
        text: "All"
    },{
        data: "data-toggle",
        href: "#pp",
        text: "Popol"
    }
];


mixin generateTabs(tabs)
    h1 tabs
        ul
            each tab in tabs
                li=tab.text


 +generateTabs(tabList)

当我尝试编译它时,我有

dev\jade\test.jade:2
    1|     - var tabList = [
  > 2|         {
    3|             data: "data-toggle",
    4|             href: "#pp",
    5|             text: "All"

unexpected text {

我正在使用Node 6.3.1,gulp-jade 1.1.0

1 个答案:

答案 0 :(得分:1)

你几乎做对了,你必须使用适当的缩进。

-
 var tabList = [
    {
        data: "data-toggle",
        href: "#pp",
        text: "All"
    },{
        data: "data-toggle",
        href: "#pp",
        text: "Popol"
    }
 ];


mixin generateTabs(tabs)
    h1 tabs
        ul
            each tab in tabs
                li=tab.text


+generateTabs(tabList)

codepen