index.js
function(str, index) {
    // replace {{ xxx }}
    var obj = this
    str = str.replace(interpolateReg, function(match, interpolate) {
      try {
        /*jslint evil: true */
        var funcNames = ['','index'].concat(fakerFuncNames).concat(['return ' + interpolate + ';']),
        func = new (Function.prototype.bind.apply(Function, funcNames)),
        funcs = [function(){return index}].concat(fakerFuncs);

        return func.apply(obj, funcs);
        
      } catch(e)  {
        return e.message;
      }
    });

    // if result is true or false, parse it to boolean
    if(/^(true|false)$/.test(str)) {
      str = str === 'true';
    }

    // if result is digit, parse it to float
    if(/^[-+]?\d*\.?\d+$/.test(str)) {
      str = parseFloat(str);
    }

    return str;
  }
function(str, index) {
    // replace {{ xxx }}
    var obj = this
    str = str.replace(interpolateReg, function(match, interpolate) {
      try {
        /*jslint evil: true */
        var funcNames = ['','index'].concat(fakerFuncNames).concat(['return ' + interpolate + ';']),
        func = new (Function.prototype.bind.apply(Function, funcNames)),
        funcs = [function(){return index}].concat(fakerFuncs);

        return func.apply(obj, funcs);
        
      } catch(e)  {
        return e.message;
      }
    });

    // if result is true or false, parse it to boolean
    if(/^(true|false)$/.test(str)) {
      str = str === 'true';
    }

    // if result is digit, parse it to float
    if(/^[-+]?\d*\.?\d+$/.test(str)) {
      str = parseFloat(str);
    }

    return str;
  }
function ( str , index ) { // replace {{ xxx }} var obj = this str = str . replace ( interpolateReg , function ( match , interpolate ) { try { /*jslint evil: true */ var funcNames = [ '' , 'index' ] . concat ( fakerFuncNames ) . concat ( [ 'return ' + interpolate + ';' ] ) , func = new ( Function . prototype . bind . apply ( Function , funcNames ) ) , funcs = [ function ( ) { return index } ] . concat ( fakerFuncs ) ; return func . apply ( obj , funcs ) ; } catch ( e ) { return e . message ; } } ) ; // if result is true or false, parse it to boolean if ( / ^(true|false)$ / . test ( str ) ) { str = str === 'true' ; } // if result is digit, parse it to float if ( / ^[-+]?\d*\.?\d+$ / . test ( str ) ) { str = parseFloat ( str ) ; } return str ; }
parse string template, if the parent template is an array, it will pass the index value to the child template
parse string template if the parent template is an array it will pass the index value to the child template