Message from JavaScript discussions

November 2017

— Updating dynamic data is possible because it can patch templates as well using the removeAttrs: false config setting

Message permanent page

— 

My equivalent (because I hate mustache and all other template engines that use that syntax)

template:
<a data-href="link" data-content-text="name"></a>

JSON:

{
link: "someLink",
name: "someName"
}

— There are also no visual side effects to load failure, so you can put in placeholders

— 

<a data-href="link" data-content-text="name">Link Not Loaded</a>

— That's where it goes, yes

— So if your data is null or something, and it doesn't load the data, the template will get loaded just like that

Message permanent page

— Placeholders

— Or you could also put some in the destination element

— Since it overwrites without append: true

— But anyways, that's just what I use for my own projects, since I like that data attribute thing and it's W3C valid still

Message permanent page

— It's actually a port of jQuery-template

— 

DialogBox.prototype.render = function () {
if (this.node === null) {
ct.loadTemplate("#dialogTemplate", "#dialogContainer", {
append: true,
data: this.data,
removeAttrs: false,
thisArg: this,
success: this.onRenderSuccess
});
} else {
ct.loadTemplate(this.node, "#dialogContainer", {
data: this.data,
removeAttrs: false,
thisArg: this,
success: this.onRenderSuccess
});
}
};

Message permanent page