How to use it

donnerjack13589 edited this page Aug 31, 2010 · 1 revision

When you require this templating system – global variable nTPL will be created.
Actually it is function so lets go through it arguments.


var template = nTPL({
  template: "Here can be filename or string containg template",
  args: ["Here", "Must", "Be", "All", "Arguments", "That", "Your", "Template","Will","Get"],
  callback: function(template){
    /* If you provide this option nTPL won't return anything, but
    *  callback will be called when template is generated
    *  P.S. All ops will be in async (file loading/reading/e.t.c)
  watch: true /* If this option is true - template will be 
                      regenerated on every file change (like in PHP) */

What should I do with this “template” variable

This template variable is function too.
So call it! It will return rendered template.


var html1 = template();
var html2 = template({
  arg1: "value",
  arg2: "value",
  arg3: "value"

Also this function holds one attribute and one method (by default):
template.unwatch();// If template was watching for file changes it will stop doing that
template.options;// Object with template options

Usage examples:

See readme