lib/application.js
function loadEngines() {
  
  // Initialize engine properties
  this.enginesByExtension = {};
  
  // Engine local variables
  var exts = [];
  var loadedEngines = this.loadedEngines = Object.keys(protos.engines);
  
  if (loadedEngines.length > 0) {
    
    // Get view engines
    var engine, instance, engineProps = ['className', 'extensions'];
    for (engine in protos.engines) {
      instance = new protos.engines[engine]();
      instance.className = instance.constructor.name;
      protos.util.onlySetEnumerable(instance, engineProps);
      this.engines[engine] = instance;
    }

    // Register engine extensions
    for (var key in this.engines) {
      engine = this.engines[key];
      exts = exts.concat(engine.extensions);
      for (var i=0; i < engine.extensions.length; i++) {
        key = engine.extensions[i];
        this.enginesByExtension[key] = engine;
      }
    }
    
    // Set default view extension if not set
    if (typeof this.config.viewExtensions.html == 'undefined') {
      this.config.viewExtensions.html = 'ejs';
    }

    // Override engine extensions (from config)
    var ext, extOverrides = this.config.viewExtensions;
    
    for (ext in extOverrides) {
      if (exts.indexOf(ext) == -1) exts.push(ext); // Register extension on `exts`
      engine = this.engines[extOverrides[ext]]; // Get engine object
      if (engine) {
        engine.extensions.push(ext); // Add ext to engine extensions
        this.enginesByExtension[ext] = engine; // Override engine extension
      } else {
        this.debug(util.format("Ignoring '%s' extension: the '%s' engine is not loaded"), ext, extOverrides[ext]);
      }
    }

    // Set default template engine
    this.defaultEngine = (this.engines.ejs || this.engines[loadedEngines[0]]);

    // Add the engines regular expression
    this.engineRegex = new RegExp('^(' + Object.keys(this.engines).join('|').replace(/\-/, '\\-') + ')$');

  }
  
  // Generate template file regex from registered template extensions
  this.regex.templateFile = new RegExp('\\.(' + exts.join('|') + ')$');
  this.templateExtensions = exts;

  this.emit('engines_loaded', this.engines); // Emit regardless
  
}
function loadEngines() {
  
  // Initialize engine properties
  this.enginesByExtension = {};
  
  // Engine local variables
  var exts = [];
  var loadedEngines = this.loadedEngines = Object.keys(protos.engines);
  
  if (loadedEngines.length > 0) {
    
    // Get view engines
    var engine, instance, engineProps = ['className', 'extensions'];
    for (engine in protos.engines) {
      instance = new protos.engines[engine]();
      instance.className = instance.constructor.name;
      protos.util.onlySetEnumerable(instance, engineProps);
      this.engines[engine] = instance;
    }

    // Register engine extensions
    for (var key in this.engines) {
      engine = this.engines[key];
      exts = exts.concat(engine.extensions);
      for (var i=0; i < engine.extensions.length; i++) {
        key = engine.extensions[i];
        this.enginesByExtension[key] = engine;
      }
    }
    
    // Set default view extension if not set
    if (typeof this.config.viewExtensions.html == 'undefined') {
      this.config.viewExtensions.html = 'ejs';
    }

    // Override engine extensions (from config)
    var ext, extOverrides = this.config.viewExtensions;
    
    for (ext in extOverrides) {
      if (exts.indexOf(ext) == -1) exts.push(ext); // Register extension on `exts`
      engine = this.engines[extOverrides[ext]]; // Get engine object
      if (engine) {
        engine.extensions.push(ext); // Add ext to engine extensions
        this.enginesByExtension[ext] = engine; // Override engine extension
      } else {
        this.debug(util.format("Ignoring '%s' extension: the '%s' engine is not loaded"), ext, extOverrides[ext]);
      }
    }

    // Set default template engine
    this.defaultEngine = (this.engines.ejs || this.engines[loadedEngines[0]]);

    // Add the engines regular expression
    this.engineRegex = new RegExp('^(' + Object.keys(this.engines).join('|').replace(/\-/, '\\-') + ')$');

  }
  
  // Generate template file regex from registered template extensions
  this.regex.templateFile = new RegExp('\\.(' + exts.join('|') + ')$');
  this.templateExtensions = exts;

  this.emit('engines_loaded', this.engines); // Emit regardless
  
}
function loadEngines ( ) { // Initialize engine properties this . enginesByExtension = { } ; // Engine local variables var exts = [ ] ; var loadedEngines = this . loadedEngines = Object . keys ( protos . engines ) ; if ( loadedEngines . length > 0 ) { // Get view engines var engine , instance , engineProps = [ 'className' , 'extensions' ] ; for ( engine in protos . engines ) { instance = new protos . engines [ engine ] ( ) ; instance . className = instance . constructor . name ; protos . util . onlySetEnumerable ( instance , engineProps ) ; this . engines [ engine ] = instance ; } // Register engine extensions for ( var key in this . engines ) { engine = this . engines [ key ] ; exts = exts . concat ( engine . extensions ) ; for ( var i = 0 ; i < engine . extensions . length ; i ++ ) { key = engine . extensions [ i ] ; this . enginesByExtension [ key ] = engine ; } } // Set default view extension if not set if ( typeof this . config . viewExtensions . html == 'undefined' ) { this . config . viewExtensions . html = 'ejs' ; } // Override engine extensions (from config) var ext , extOverrides = this . config . viewExtensions ; for ( ext in extOverrides ) { if ( exts . indexOf ( ext ) == - 1 ) exts . push ( ext ) ; // Register extension on `exts` engine = this . engines [ extOverrides [ ext ] ] ; // Get engine object if ( engine ) { engine . extensions . push ( ext ) ; // Add ext to engine extensions this . enginesByExtension [ ext ] = engine ; // Override engine extension } else { this . debug ( util . format ( "Ignoring '%s' extension: the '%s' engine is not loaded" ) , ext , extOverrides [ ext ] ) ; } } // Set default template engine this . defaultEngine = ( this . engines . ejs || this . engines [ loadedEngines [ 0 ] ] ) ; // Add the engines regular expression this . engineRegex = new RegExp ( '^(' + Object . keys ( this . engines ) . join ( '|' ) . replace ( / \- / , '\\-' ) + ')$' ) ; } // Generate template file regex from registered template extensions this . regex . templateFile = new RegExp ( '\\.(' + exts . join ( '|' ) + ')$' ) ; this . templateExtensions = exts ; this . emit ( 'engines_loaded' , this . engines ) ; // Emit regardless }
Loads view engines
Loads view engines