ContentLayout 的 render(params) 方法可呈現來自樣板的內容版面配置。對於內容版面配置,預設會使用 Mustache 樣板,但您可以使用任何想要的樣板技術。
ContentLayout 的 render(params) 方法可以使用下列程式碼來呈現含有資料的樣板:
try {
// Mustache
template = Mustache.render(templateHtml, content);
if (template) {
$(parentObj).append(template);
}
// Dynamic DOM Manipulation can be done here
} catch (e) {
console.error(e.stack);
}
您可以將所需資料新增至從 params.contentItemData 建立的 content 物件。Oracle 建議您將來自 params.scsData 的特性合併到此物件中,以便讓樣板也能使用這些特性。所呈現的樣板應該附加至傳送給 render() 方法的父項物件。