【发布时间】:2016-05-27 16:06:09
【问题描述】:
我正在尝试在 Jade / Pug 中使用原子设计模式来创建一个包含链接的简单列表。我的列表混合如下,并接受一个项目数组:
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
在我的模板中,我有以下内容:
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'
]})
我收到一个错误:
link is not a function
但是,如果我使用该 items 数组之外的链接,它就可以正常工作。我做错了什么?
【问题讨论】:
-
旁注:翡翠不再叫翡翠,it's going to be pug now.
-
添加了哈巴狗。无法标记它,因为 pug 还不是标记,而且我的排名不够高,无法添加!