Message from JavaScript discussions

November 2017

— And supports formatting

— 

// Initialize an instance of cdaTemplate.
var loader = new cdaTemplate();

// Add a custom data formatter.
// This one returns `input` with all uppercase letters.
loader.addFormatter("myFormatter", input => input.toUpperCase());

// Set up the data source.
var dataSource = {
myTag: "Hello World!"
};

// Load the template.
loader.loadTemplate("#myTemplate", "#myContainer", {
data: dataSource
});

— Yes, this is because it uses a cache

— And a configuration object

— So you can init multiple with different configs, designed for different types of templates

— Function?

— Like adding event listener?

— You can add them easily by using success

loader.loadTemplate("#myTemplate", "#myContainer", {
data: dataSource,
success: insertedNode => insertedNode.addEventListener("click", myFunc)
});

Message permanent page

— There are formatters that can mutate tag strings

— All this does is inject data into a predefined template and insert it into a destination node

— TagStrings, yes

— You can set a namespaceURI though and query it