mixin pug

Solutions on MaxInterview for mixin pug by the best coders in the world

showing results for - "mixin pug"
Mia
10 Sep 2017
1mixin listitem(spec)
2    - spec = spec || {}
3    - spec.__class = spec.__class || ''
4    - spec.content = spec.content || ''
5
6    li(class=spec.__class)&attributes(attributes)
7       if (typeof spec.content === 'string') 
8         != spec.content
9       else
10         block
11
12mixin link(spec)
13    - spec = spec || {}
14    - spec.__class = spec.__class || ''
15    - spec.text = spec.text || 'Default Link'
16    - attributes = spec.attributes || ''
17
18
19    a.link(class=spec.__class)&attributes(attributes)
20        if block
21            block
22        else
23            != spec.text
24
25
26mixin list(spec)
27    - spec = spec || {}
28    - spec.__class = spec.__class || ''
29    - spec.type = spec.type || 'ul'
30    - spec.items = spec.items || {}
31
32    if spec.items.length
33        #{spec.type}
34            for item in spec.items
35               +listitem({content: item})
36                 if (item[0])
37                   +link(item[0])
38
39
40block content
41    +list({items: [
42        'list item 1',
43        'list item 2',
44        [{text: "Hi link"}],
45        'list item 4'
46    ]})