[英]How to bind data to attributes inside an array of objects using the Plates templating engine?
多年來 ,隨着Plates的不斷變化的稅法 (不再適用)和糟糕的文檔記錄,
我有這個字符串:
<table id="group">
<tr>
<td class="name"></td>
<td>
<a class="surname"></a>
</td>
</tr>
</table>
而這個數據:
{
group: [{
name: 'Ludwig',
surname: 'von Mises',
url: 'http://mises.org/'
}, {
name: 'Friedrich',
surname: 'Hayek',
url: 'http://hayek.org/'
}],
}
我應該怎么做才能將url
綁定到href
,所以我得到
<table id="group">
<tr>
<td class="name">Ludwig</td>
<td>
<a class="surname" href="http://mises.org/">Mises</a>
</td>
</tr>
<tr>
<td class="name">Friedrich</td>
<td>
<a class="surname" href="http://hayek.org/">Hayek</a>
</td>
</tr>
</table>
?
面對其他人的庫的一個簡單問題,我做了任何程序員在這種情況下都會做的事情:我編寫了自己的(可能)工作的類似於Plates的模板引擎(但不是其中的一個)。
它在這里: https : //github.com/fiatjaf/tempreites
(適用於字符串,語義綁定,僅一個文件,沒有依賴項,一個名為render
的簡單同步函數,就是它。)
(我在此處發布此問題后就開始編寫它,因此,這不僅僅是為了宣傳。)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.