10
我有一個不尋常的情況,客戶想要在從JSON對象傳遞給handlebars的字符串中放置換行符。我嘗試過轉義字符,但它並不意外地被DOM渲染。有什麼建議麼?將HTML標記傳遞到handleBars
"company": "Lorem adscs ireland <br/> marketed as iuhmdsf in Europe"
var products = Data;
var theTemplateScript = $("#product-template").html();
var theTemplate = Handlebars.compile (theTemplateScript);
$("#marketed-products .products").append (theTemplate(products));
{{#items}}
<li><span class="company">{{company}}</li>
{{/items}}
從上面的代碼的輸出應該是這個樣子
的Lorem脂肪幹細胞愛爾蘭
作爲iuhmdsf在歐洲銷售
你讓我錯了,請參閱編輯答案。 – aram90 2013-03-19 17:11:07
我認爲答案是相當現場的。看到這裏:http://jsfiddle.net/86Avr/ – svckr 2013-03-19 17:30:15
是的,這很好,我做了它後,我刪除了我的評論。我的錯。 – 2013-03-19 17:37:44