应用多个 类 的方法,它在 Pug 中占用多于一行而不复制属性

Ways to apply multiple classes which take more that one line in Pug without attribute duplicating

我想使用 "disallowDuplicateAttributes" rule from pug-lint,这显然不允许属性重复。基本上,当我们需要应用多个长 class 名称时,属性复制需要:

td(
  class="ProductsManagementPage-ProductsTable-ProductsTableHeaderDecoration"
  class="ProductsManagementPage-ProductsTable-ID_ColumnSizer"
  class="ProductsManagementPage-ProductsTable-ID_ColumnDecoration"
)

还有哪些方法可行?

不允许的解决方案

  1. 将所有 classes 链接到带有 class 文字的单行中,因为它会影响可维护性。此外,我将使用相同的 pug-lint 限制每行的列数。
td.ProductsManagementPage-ProductsTable-ProductsTableHeaderDecoration.ProductsManagementPage-ProductsTable-ID_ColumnSizer.ProductsManagementPage-ProductsTable-ID_ColumnDecoration

像这样链接 类:

td.ProductsManagementPage-ProductsTable-ProductsTableHeaderDecoration.ProductsManagementPage-ProductsTable-ID_ColumnSizer.ProductsManagementPage-ProductsTable-ID_ColumnDecoration

类 的数组可以通过 attributes literal 指定。超长 类 可以通过字符串连接拆分:

td&attributes({
  class: [
    "ProductsManagementPage-ProductsTable-ProductsTableHeaderDecoration",
    "ProductsManagementPage-" + 
            "ProductsTable-ID_ColumnSizer",
    "ProductsManagementPage-ProductsTable-ID_ColumnDecoration"
  ]
}) 有