libs/lodash.js
function template(string, data, options) {
      // based on John Resig's `tmpl` implementation
      // http://ejohn.org/blog/javascript-micro-templating/
      // and Laura Doktorova's doT.js
      // https://github.com/olado/doT
      var settings = lodash.templateSettings;
      options = defaults({}, options, settings);
      string = String(string == null ? '' : string);

      var imports = defaults({}, options.imports, settings.imports),
          importsKeys = keys(imports),
          importsValues = values(imports);

      var isEscaping,
          isEvaluating,
          index = 0,
          interpolate = options.interpolate || reNoMatch,
          source = "__p += '";

      // compile the regexp to match each delimiter
      var reDelimiters = RegExp(
        (options.escape || reNoMatch).source + '|' +
        interpolate.source + '|' +
        (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
        (options.evaluate || reNoMatch).source + '|$'
      , 'g');

      string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
        interpolateValue || (interpolateValue = esTemplateValue);

        // escape characters that cannot be included in string literals
        source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);

        // replace delimiters with snippets
        if (escapeValue) {
          isEscaping = true;
          source += "' +\n__e(" + escapeValue + ") +\n'";
        }
        if (evaluateValue) {
          isEvaluating = true;
          source += "';\n" + evaluateValue + ";\n__p += '";
        }
        if (interpolateValue) {
          source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
        }
        index = offset + match.length;

        // the JS engine embedded in Adobe products requires returning the `match`
        // string in order to produce the correct `offset` value
        return match;
      });

      source += "';\n";

      // if `variable` is not specified, wrap a with-statement around the generated
      // code to add the data object to the top of the scope chain
      var variable = options.variable;
      if (!variable) {
        source = 'with (obj) {\n' + source + '\n}\n';
      }
      // cleanup code by stripping empty strings
      source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
        .replace(reEmptyStringMiddle, '$1')
        .replace(reEmptyStringTrailing, '$1;');

      // frame code as the function body
      source = 'function(' + (variable || 'obj') + ') {\n' +
        (variable
          ? ''
          : 'obj || (obj = {});\n'
        ) +
        "var __t, __p = ''" +
        (isEscaping
           ? ', __e = _.escape'
           : ''
        ) +
        (isEvaluating
          ? ', __j = Array.prototype.join;\n' +
            "function print() { __p += __j.call(arguments, '') }\n"
          : ';\n'
        ) +
        source +
        'return __p\n}';

      // Use a `sourceURL` for easier debugging.
      // http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl
      var sourceURL = '\n/*\n//# sourceURL=' + (options.sourceURL || '/lodash/template/source[' + (templateCounter++) + ']') + '\n*/';

      try {
        var result = Function(importsKeys, 'return ' + source + sourceURL).apply(undefined, importsValues);
      } catch(e) {
        e.source = source;
        throw e;
      }
      if (data) {
        return result(data);
      }
      // provide the compiled function's source by its `toString` method, in
      // supported environments, or the `source` property as a convenience for
      // inlining compiled templates during the build process
      result.source = source;
      return result;
    }
function template(string, data, options) {
      // based on John Resig's `tmpl` implementation
      // http://ejohn.org/blog/javascript-micro-templating/
      // and Laura Doktorova's doT.js
      // https://github.com/olado/doT
      var settings = lodash.templateSettings;
      options = defaults({}, options, settings);
      string = String(string == null ? '' : string);

      var imports = defaults({}, options.imports, settings.imports),
          importsKeys = keys(imports),
          importsValues = values(imports);

      var isEscaping,
          isEvaluating,
          index = 0,
          interpolate = options.interpolate || reNoMatch,
          source = "__p += '";

      // compile the regexp to match each delimiter
      var reDelimiters = RegExp(
        (options.escape || reNoMatch).source + '|' +
        interpolate.source + '|' +
        (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
        (options.evaluate || reNoMatch).source + '|$'
      , 'g');

      string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
        interpolateValue || (interpolateValue = esTemplateValue);

        // escape characters that cannot be included in string literals
        source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);

        // replace delimiters with snippets
        if (escapeValue) {
          isEscaping = true;
          source += "' +\n__e(" + escapeValue + ") +\n'";
        }
        if (evaluateValue) {
          isEvaluating = true;
          source += "';\n" + evaluateValue + ";\n__p += '";
        }
        if (interpolateValue) {
          source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
        }
        index = offset + match.length;

        // the JS engine embedded in Adobe products requires returning the `match`
        // string in order to produce the correct `offset` value
        return match;
      });

      source += "';\n";

      // if `variable` is not specified, wrap a with-statement around the generated
      // code to add the data object to the top of the scope chain
      var variable = options.variable;
      if (!variable) {
        source = 'with (obj) {\n' + source + '\n}\n';
      }
      // cleanup code by stripping empty strings
      source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
        .replace(reEmptyStringMiddle, '$1')
        .replace(reEmptyStringTrailing, '$1;');

      // frame code as the function body
      source = 'function(' + (variable || 'obj') + ') {\n' +
        (variable
          ? ''
          : 'obj || (obj = {});\n'
        ) +
        "var __t, __p = ''" +
        (isEscaping
           ? ', __e = _.escape'
           : ''
        ) +
        (isEvaluating
          ? ', __j = Array.prototype.join;\n' +
            "function print() { __p += __j.call(arguments, '') }\n"
          : ';\n'
        ) +
        source +
        'return __p\n}';

      // Use a `sourceURL` for easier debugging.
      // http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl
      var sourceURL = '\n/*\n//# sourceURL=' + (options.sourceURL || '/lodash/template/source[' + (templateCounter++) + ']') + '\n*/';

      try {
        var result = Function(importsKeys, 'return ' + source + sourceURL).apply(undefined, importsValues);
      } catch(e) {
        e.source = source;
        throw e;
      }
      if (data) {
        return result(data);
      }
      // provide the compiled function's source by its `toString` method, in
      // supported environments, or the `source` property as a convenience for
      // inlining compiled templates during the build process
      result.source = source;
      return result;
    }
function template ( string , data , options ) { // based on John Resig's `tmpl` implementation // http://ejohn.org/blog/javascript-micro-templating/ // and Laura Doktorova's doT.js // https://github.com/olado/doT var settings = lodash . templateSettings ; options = defaults ( { } , options , settings ) ; string = String ( string == null ? '' : string ) ; var imports = defaults ( { } , options . imports , settings . imports ) , importsKeys = keys ( imports ) , importsValues = values ( imports ) ; var isEscaping , isEvaluating , index = 0 , interpolate = options . interpolate || reNoMatch , source = "__p += '" ; // compile the regexp to match each delimiter var reDelimiters = RegExp ( ( options . escape || reNoMatch ) . source + '|' + interpolate . source + '|' + ( interpolate === reInterpolate ? reEsTemplate : reNoMatch ) . source + '|' + ( options . evaluate || reNoMatch ) . source + '|$' , 'g' ) ; string . replace ( reDelimiters , function ( match , escapeValue , interpolateValue , esTemplateValue , evaluateValue , offset ) { interpolateValue || ( interpolateValue = esTemplateValue ) ; // escape characters that cannot be included in string literals source += string . slice ( index , offset ) . replace ( reUnescapedString , escapeStringChar ) ; // replace delimiters with snippets if ( escapeValue ) { isEscaping = true ; source += "' +\n__e(" + escapeValue + ") +\n'" ; } if ( evaluateValue ) { isEvaluating = true ; source += "';\n" + evaluateValue + ";\n__p += '" ; } if ( interpolateValue ) { source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'" ; } index = offset + match . length ; // the JS engine embedded in Adobe products requires returning the `match` // string in order to produce the correct `offset` value return match ; } ) ; source += "';\n" ; // if `variable` is not specified, wrap a with-statement around the generated // code to add the data object to the top of the scope chain var variable = options . variable ; if ( ! variable ) { source = 'with (obj) {\n' + source + '\n}\n' ; } // cleanup code by stripping empty strings source = ( isEvaluating ? source . replace ( reEmptyStringLeading , '' ) : source ) . replace ( reEmptyStringMiddle , '$1' ) . replace ( reEmptyStringTrailing , '$1;' ) ; // frame code as the function body source = 'function(' + ( variable || 'obj' ) + ') {\n' + ( variable ? '' : 'obj || (obj = {});\n' ) + "var __t, __p = ''" + ( isEscaping ? ', __e = _.escape' : '' ) + ( isEvaluating ? ', __j = Array.prototype.join;\n' + "function print() { __p += __j.call(arguments, '') }\n" : ';\n' ) + source + 'return __p\n}' ; // Use a `sourceURL` for easier debugging. // http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl var sourceURL = '\n/*\n//# sourceURL=' + ( options . sourceURL || '/lodash/template/source[' + ( templateCounter ++ ) + ']' ) + '\n*/' ; try { var result = Function ( importsKeys , 'return ' + source + sourceURL ) . apply ( undefined , importsValues ) ; } catch ( e ) { e . source = source ; throw e ; } if ( data ) { return result ( data ) ; } // provide the compiled function's source by its `toString` method, in // supported environments, or the `source` property as a convenience for // inlining compiled templates during the build process result . source = source ; return result ; }
Creates a compiled template function that can interpolate data properties
in "interpolate" delimiters, HTML-escaped interpolated data properties in
"escape" delimiters, and execute JavaScript in "evaluate" delimiters. If
a data object is provided the interpolated template string will be returned.
Data properties may be accessed as free variables in the template. If a
settings object is provided it will override `_.templateSettings` for the
template.

Note: In the development build, `_.template` utilizes `sourceURL`s for easier debugging.
See the [HTML5 Rocks article on sourcemaps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
for more details.

For more information on precompiling templates see
[Lo-Dash's custom builds documentation](http://lodash.com/custom-builds).

For more information on Chrome extension sandboxes see
[Chrome's extensions documentation](http://developer.chrome.com/stable/extensions/sandboxingEval.html).

@static
@memberOf _
@category Strings
@param {string} [string=''] The template string.
@param {Object} [data] The data object used to populate the template string.
@param {Object} [options] The options object.
@param {RegExp} [options.escape] The HTML "escape" delimiter.
@param {RegExp} [options.evaluate] The "evaluate" delimiter.
@param {Object} [options.imports] An object to import into the template as local variables.
@param {RegExp} [options.interpolate] The "interpolate" delimiter.
@param {string} [options.sourceURL] The `sourceURL` of the template's compiled source.
@param {string} [options.variable] The data object variable name.
@returns {Function|string} Returns the interpolated string if a data object
is provided, else the compiled template function.
@example

// using the "interpolate" delimiter to create a compiled template
var compiled = _.template('hello <%= name %>');
compiled({ 'name': 'fred' });
// => 'hello fred'

// using the HTML "escape" delimiter to escape data property values
_.template('<b><%- value %></b>', { 'value': '<script>' });
// => '<b>&lt;script&gt;</b>'

// using the "evaluate" delimiter to execute JavaScript and generate HTML
var list = '<% _.forEach(people, function(name) { %><li><%- name %></li><% }); %>';
_.template(list, { 'people': ['fred', 'barney'] });
// => '<li>fred</li><li>barney</li>'

// using the ES6 delimiter as an alternative to the default "interpolate" delimiter
_.template('hello ${ name }', { 'name': 'pebbles' });
// => 'hello pebbles'

// using the internal `print` function in "evaluate" delimiters
_.template('<% print("hello " + name); %>!', { 'name': 'barney' });
// => 'hello barney!'

// using a custom template delimiters
_.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
_.template('hello {{ name }}!', { 'name': 'mustache' });
// => 'hello mustache!'

// using the `imports` option to import jQuery
var list = '<% jq.each(people, function(name) { %><li><%- name %></li><% }); %>';
_.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { 'jq': jQuery } });
// => '<li>fred</li><li>barney</li>'

// using the `sourceURL` option to specify a custom `sourceURL` for the template
var compiled = _.template('hello <%= name %>', null, { 'sourceURL': '/basic/greeting.jst' });
compiled(data);
// => find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector

// using the `variable` option to ensure a with-statement isn't used in the compiled template
var compiled = _.template('hi <%= data.name %>!', null, { 'variable': 'data' });
compiled.source;
// => function(data) {
var __t, __p = '', __e = _.escape;
__p += 'hi ' + ((__t = ( data.name )) == null ? '' : __t) + '!';
return __p;
}

// using the `source` property to inline compiled templates for meaningful
// line numbers in error messages and a stack trace
fs.writeFileSync(path.join(cwd, 'jst.js'), '\
var JST = {\
"main": ' + _.template(mainText).source + '\
};\
');
Creates a compiled template function that can interpolate data properties in interpolate delimiters HTML - escaped interpolated data properties in escape delimiters and execute JavaScript in evaluate delimiters . If a data object is provided the interpolated template string will be returned . Data properties may be accessed as free variables in the template . If a settings object is provided it will override _ . templateSettings for the template .