index.js
function builtTemplateFromString(str, filename, options) {

  try {
    var config = {};

    // config at the beginning of the file
    str.replace(settings.config, function(m, conf) {
      config = yaml.safeLoad(conf);
    });

    // strip comments
    if (settings.stripComment) {
      str = str.replace(settings.comment, function(m, code, assign, value) {
        return '';
      });
    }

    // strip whitespace
    if (settings.stripWhitespace) {
      settings.dot.strip = settings.stripWhitespace;
    }

    // layout sections
    var sections = {};

    if (!config.layout) {
      sections.body = str;
    }
    else {
      str.replace(settings.dot.define, function(m, code, assign, value) {
        sections[code] = value;
      });
    }

    var templateSettings = _.pick(options, ['settings']);
    options.getTemplate && (templateSettings.getTemplate = options.getTemplate);
    return new Template({
      express: templateSettings,
      config: config,
      sections: sections,
      dirname: path.dirname(filename),
      filename: filename
    });
  }
  catch (err) {
    throw new Error(
      'Failed to build template' +
      ' (' + filename + ')' +
      ' - ' + err.toString()
    );
  }
}
function builtTemplateFromString(str, filename, options) {

  try {
    var config = {};

    // config at the beginning of the file
    str.replace(settings.config, function(m, conf) {
      config = yaml.safeLoad(conf);
    });

    // strip comments
    if (settings.stripComment) {
      str = str.replace(settings.comment, function(m, code, assign, value) {
        return '';
      });
    }

    // strip whitespace
    if (settings.stripWhitespace) {
      settings.dot.strip = settings.stripWhitespace;
    }

    // layout sections
    var sections = {};

    if (!config.layout) {
      sections.body = str;
    }
    else {
      str.replace(settings.dot.define, function(m, code, assign, value) {
        sections[code] = value;
      });
    }

    var templateSettings = _.pick(options, ['settings']);
    options.getTemplate && (templateSettings.getTemplate = options.getTemplate);
    return new Template({
      express: templateSettings,
      config: config,
      sections: sections,
      dirname: path.dirname(filename),
      filename: filename
    });
  }
  catch (err) {
    throw new Error(
      'Failed to build template' +
      ' (' + filename + ')' +
      ' - ' + err.toString()
    );
  }
}
function builtTemplateFromString ( str , filename , options ) { try { var config = { } ; // config at the beginning of the file str . replace ( settings . config , function ( m , conf ) { config = yaml . safeLoad ( conf ) ; } ) ; // strip comments if ( settings . stripComment ) { str = str . replace ( settings . comment , function ( m , code , assign , value ) { return '' ; } ) ; } // strip whitespace if ( settings . stripWhitespace ) { settings . dot . strip = settings . stripWhitespace ; } // layout sections var sections = { } ; if ( ! config . layout ) { sections . body = str ; } else { str . replace ( settings . dot . define , function ( m , code , assign , value ) { sections [ code ] = value ; } ) ; } var templateSettings = _ . pick ( options , [ 'settings' ] ) ; options . getTemplate && ( templateSettings . getTemplate = options . getTemplate ) ; return new Template ( { express : templateSettings , config : config , sections : sections , dirname : path . dirname ( filename ) , filename : filename } ) ; } catch ( err ) { throw new Error ( 'Failed to build template' + ' (' + filename + ')' + ' - ' + err . toString ( ) ) ; } }
Builds a template from a string
@param {String} str The template string
@param {String} filename The path to the template
@param {Object} options The options sent by express
@return {Template} The template object
Builds a template from a string