Skip to content

Instantly share code, notes, and snippets.

@MichMich
Last active September 27, 2017 16:18
Show Gist options
  • Save MichMich/2a1e97a25e91a5d9ba3670dcccff3d15 to your computer and use it in GitHub Desktop.
Save MichMich/2a1e97a25e91a5d9ba3670dcccff3d15 to your computer and use it in GitHub Desktop.
Templating Example
Module.register("helloworld",{
/* ... */
getTemplate: function () {
// Should return a String: the template filename.
// We could also allow users to return a template string,
// and check if the string ends with `.html` in that case
// use the file, otherwiste the literal string.
//
// The default implementation schould be a templete string
// containing the Modules name (for debugging), which is
// currently the default getDom implementation.
//
// The template or templateString will be parsed into
// a dom object and used by the default getDom implementation.
return "helloworld.html"
},
getTemplateData: function () {
// Should return an object.
// If this method is not defined, the default implementation in module.js
// should return an empty object {}
return {name: "Michael"}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment