Pug Jade:在嵌套标签元素上循环

时间:2018-08-27 16:07:00

标签: pug

我在Pug / Jade中的for / each循环有问题。 我想循环并打印4次嵌套的标记元素。标签是这样的:

<div class="profile">
    <div class="id">ID Personne: 1</div>
    <div class="fullName">Nom complet: Full Name</div>
    <div class="description">Description: Some Text</div>
    <div class="initialMoney>Argent initial: 0</div>
    <div class="totalMoney">Argent total cumulé: 500</div>
    <div class="transactions">
        <div class="transaction">...</div>
        <div class="transaction">...</div>
        <div class="transaction">...</div>
    </div>
</div>

我尝试了for循环,但是没有用!它仅打印数组的第一个元素!它只显示一个div.profile标签! 这是我的代码:

for person in persons
    .profile= person
        .id= 'ID Personne: '+person._id
        .fullName= 'Nom complet: '+person.fullName
        .description= 'Description: '+person.description
        .initialMoney= 'Argent initial: '+person.initialMoney
        .totalMoney= 'Argent total cumulé: '+prettyAccumulate+'Dhs'
        .transactions
            if person.transaction
                each transaction in person.transaction
                    .transaction= transaction.id+' '+transaction.fullName+' '+(transaction.add==true?'+':'-')+transaction.money+'Dhs '+transaction.date
            else
                strong Pas de transactions

谢谢您的帮助!

0 个答案:

没有答案