lib/js/Template.js
function(params, options) {
      var t = this;

      // If raw text was sent to the template, compile and return
      if (t.get('text')) {
        t.compile();
        return;
      }

      // Watch for changes in the text element
      t.on('change:text', t.compile, t);

      // Process a file template
      var path = t.get('path');
      if (path) {
        // Load the file
        if (t.asyncLoad) {
          FS.readFile(path, function(err, text) {
            if (err) {
              return console.error('Error reading file: ' + path, err);
            }
            t.set({text: text.toString()});
          });
        } else {
          t.set({text: FS.readFileSync(path).toString()});
        }

        // Watch the file for changes
        if (t.get('watchFile')) {
          t._watchFile();
        }
      }
    }
function(params, options) {
      var t = this;

      // If raw text was sent to the template, compile and return
      if (t.get('text')) {
        t.compile();
        return;
      }

      // Watch for changes in the text element
      t.on('change:text', t.compile, t);

      // Process a file template
      var path = t.get('path');
      if (path) {
        // Load the file
        if (t.asyncLoad) {
          FS.readFile(path, function(err, text) {
            if (err) {
              return console.error('Error reading file: ' + path, err);
            }
            t.set({text: text.toString()});
          });
        } else {
          t.set({text: FS.readFileSync(path).toString()});
        }

        // Watch the file for changes
        if (t.get('watchFile')) {
          t._watchFile();
        }
      }
    }
function ( params , options ) { var t = this ; // If raw text was sent to the template, compile and return if ( t . get ( 'text' ) ) { t . compile ( ) ; return ; } // Watch for changes in the text element t . on ( 'change:text' , t . compile , t ) ; // Process a file template var path = t . get ( 'path' ) ; if ( path ) { // Load the file if ( t . asyncLoad ) { FS . readFile ( path , function ( err , text ) { if ( err ) { return console . error ( 'Error reading file: ' + path , err ) ; } t . set ( { text : text . toString ( ) } ) ; } ) ; } else { t . set ( { text : FS . readFileSync ( path ) . toString ( ) } ) ; } // Watch the file for changes if ( t . get ( 'watchFile' ) ) { t . _watchFile ( ) ; } } }
Initialize the template
Initialize the template