Reputation: 127
I have the following json file:
{
"leadership": [
{
"leadername": "Name1",
"leaderjob": "Chairman",
"leaderdescription": "The boss"
},
{
"leadername": "Name2",
"leaderjob": "Chief Executive Officer",
"leaderdescription": "Other boss"
}
]
}
and if I try to get the content with the following mixin:
mixin defList(obj)
dl.deflist
each item in obj
dt= item.leadername
dd= item.leaderdescription
by calling it like this
+defList(leadership)
everything works fine, but what I would like to have is this:
mixin defList(obj, name, description)
dl.deflist
each item in obj
dt= name
dd= description
so I would be able to call it like this:
+defList(leadership, leadername, leaderdescription)
but unfortunately I get only empty dt and dd tags.
Is there any way to make it work and populate the list? I can't figure out what am I doing wrong.
Upvotes: 1
Views: 565
Reputation: 11
If I understood correctly your question, you would solve like this:
mixin defList(obj, name, description)
dl.deflist
each item in obj
dt= item[name]
dd= item[description]
then:
+defList(leadership, "leadername", "leaderdescription")
Result:
<dl class="deflist"><dt>Name1</dt><dd>The boss</dd><dt>Name2</dt><dd>Other boss</dd></dl>
Upvotes: 1