Javascript 从Jade中的对象键:值对添加属性
给定具有未知键值对的对象数组:Javascript 从Jade中的对象键:值对添加属性,javascript,pug,Javascript,Pug,给定具有未知键值对的对象数组: meta: [ { name: 'description', content: 'some description' }, { name: 'keywords', content: 'some keywords' } ] 使用我想输出: <meta name="description" content="some description" /> <meta name="keyword" content="some keywords" /
meta: [
{ name: 'description', content: 'some description' },
{ name: 'keywords', content: 'some keywords' }
]
使用我想输出:
<meta name="description" content="some description" />
<meta name="keyword" content="some keywords" />
显然是无效的,也不知道该怎么做。谢谢 答案非常简单,使用:
each m in meta
meta(
each val, key in m ..print them
)
each m in meta
meta()&attributes(m)