Jade/Pugのアトミックデザインパターンを使用して、リンクが含まれる単純なリストを作成しようとしています。Jade/Pug:別のmixinのパラメーター配列にmixinを使用する方法
include ../../atoms/listitem/listitem
mixin list(spec)
- spec = spec || {}
- spec.__class = spec.__class || ''
- spec.type = spec.type || 'ul'
- spec.items = spec.items || {}
if spec.items.length
#{spec.type}
for item in spec.items
+listitem({content: item})
リスト項目:
mixin listitem(spec)
- spec = spec || {}
- spec.__class = spec.__class || ''
- spec.content = spec.content || ''
li(class=spec.__class)&attributes(attributes)
!= spec.content
リンク:
mixin link(spec)
- spec = spec || {}
- spec.__class = spec.__class || ''
- spec.text = spec.text || 'Default Link'
a.link(class=spec.__class)&attributes(attributes)
if block
block
else
!= spec.text
そして、私のテンプレートでは、私が持っている
次 以下のアイテムの配列を受け入れるように私のリストのmixinですinclude _modules/atoms/link/link
include _modules/molecules/list/list
block content
+list({items: [
'list item 1',
'list item 2',
+link({text: "Hi link"})(href="#"),
'list item 4'
]})
私はror:
しかし、私はその項目の配列の外のリンクを使用すればうまくいきます。私は間違って何をしていますか?
追記:ヒスイはもはやヒスイと呼ばれ、(https://github.com/pugjs/pug/issues/2184)[今パグになるだろう]。 –
pugが追加されました。パグはまだタグではないので、タグ付けできませんでした。 – Bat