index.js
function getTemplateContentFromFile(filename, options, callback) {
  var isAsync = callback && typeof callback === 'function';

  // sync
  if (!isAsync) {
    return fs.readFileSync(filename, 'utf8');
  }

  // async
  fs.readFile(filename, 'utf8', function(err, str) {
    if (err) {
      callback(new Error('Failed to open view file (' + filename + ')'));
      return;
    }

    try {
      callback(null, str);
    }
    catch (err) {
      callback(err);
    }
  });
}
function getTemplateContentFromFile(filename, options, callback) {
  var isAsync = callback && typeof callback === 'function';

  // sync
  if (!isAsync) {
    return fs.readFileSync(filename, 'utf8');
  }

  // async
  fs.readFile(filename, 'utf8', function(err, str) {
    if (err) {
      callback(new Error('Failed to open view file (' + filename + ')'));
      return;
    }

    try {
      callback(null, str);
    }
    catch (err) {
      callback(err);
    }
  });
}
function getTemplateContentFromFile ( filename , options , callback ) { var isAsync = callback && typeof callback === 'function' ; // sync if ( ! isAsync ) { return fs . readFileSync ( filename , 'utf8' ) ; } // async fs . readFile ( filename , 'utf8' , function ( err , str ) { if ( err ) { callback ( new Error ( 'Failed to open view file (' + filename + ')' ) ) ; return ; } try { callback ( null , str ) ; } catch ( err ) { callback ( err ) ; } } ) ; }
Gets the template content from a file
If callback is passed, it will be called asynchronously.
@param {String} filename The path to the template
@param {Object} options The options sent by express
@param {Function} callback (Optional) The async node style callback
Gets the template content from a file If callback is passed it will be called asynchronously .