/*
Replace {{foo}} and friends with values from our view
434341
function(template, context, partials, in_recursion) {
        // tit for tat
        var that = this;

        var new_regex = function() {
          return new RegExp(that.otag + "(=|!|>|\\{|%)?([^\\/#\\^]+?)\\1?" +
            that.ctag + "+", "g");
        };

        var regex = new_regex();
        var tag_replace_callback = function(match, operator, name) {
          switch(operator) {
          case "!": // ignore comments
            return "";
          case "=": // set new delimiters, rebuild the replace regexp
            that.set_delimiters(name);
            regex = new_regex();
            return "";
          case ">": // render partial
            return that.render_partial(name, context, partials);
          case "{": // the triple mustache is unescaped
            return that.find(name, context);
          default: // escape the value
            return that.escape(that.find(name, context));
          }
        };
        var lines = template.split("\n");
        for(var i = 0; i < lines.length; i++) {
          lines[i] = lines[i].replace(regex, tag_replace_callback, this);
          if(!in_recursion) {
            this.send(lines[i]);
          }
        }

        if(in_recursion) {
          return lines.join("\n");
        }
      }
1139881
function(name, value) {
			if (arguments.length == 2) {
				if (value === null) {
					// remove attribute
					var vals = this._attributes.filter(function(attr) {
						return attr.name === name;
					});

					var that = this;
					vals.forEach(function(attr) {
						var ix = that._attributes.indexOf(attr);
						if (~ix) {
							that._attributes.splice(ix, 1);
						}
					});

					return;
				}

				// modify attribute
				var attrNames = this._attributes.map(function(attr) {
					return attr.name;
				});
				var ix = attrNames.indexOf(name.toLowerCase());
				if (~ix) {
					this._attributes[ix].value = value;
				} else {
					this._attributes.push({
						name: name,
						value: value
					});
				}
			}
			
			return (utils.find(this.attributeList(), function(attr) {
				return attr.name == name;
			}) || {}).value;
		}
188364
function (content, block, target, type) {
            target = target || 'replace';

            return helpers['useref_' + type](content, block, target);
        }
601189
function replace(regex, source, options) {
  var valueOrFn = getValueOrMatchFn(options.value)
  source.replace(regex, function () { return '' })
  return source.replace(regex, valueOrFn)
}
1140477
function template(str, params){
  return str.replace(/%(\w*)%/g, function(m, key){
    return params[key];
  });
}
981922
function $value(value) {
      function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }
      function $replace(value) {
        var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });
        return replacement.length ? replacement[0] : value;
      }
      value = $replace(value);
      return !isDefined(value) ? $$getDefaultValue() : self.type.$normalize(value);
    }
895131
function replaceAll(str, find, replace) {
	let s = '',
		index,
		next;
	while (~(next = str.indexOf(find, index))) {
		s += str.substring(index, next) + replace;
		index = next + find.length;
	}
	return s + str.substring(index);
}
463435
function(replace, count, callback) {
    return pathmap.replace(
      pathmap.basename(this, pathmap.extname(this)), replace, callback);
  }
1178887
function (context) {
        var replacements;
        if (context) {
            replacements = {};
            _gpfObjectForEach(context, function (value, key) {
                replacements["{" + key + "}"] = value.toString();
            });
            this.message = _gpfStringReplaceEx(this.message, replacements);
        }
    }
1329139
function str_replace(names, values, str) {
  names.forEach((name, idx) => {
    str = str.replace(names[idx], values[idx]);
  });
  return str;
}
1174339
function replaceWith(to, params, query) {
    this.context.router.replaceWith(to, params, query);
  }
515062
function jsonReplacer(key, value) {
  if (value && (value.DAO || value.sequelize)) {
    return value.name || '';
  }
  return value;
}
1242495
function replaceStringPlaceholders(string, args) {
    for (var i = 1; i < args.length; i++) {
        var value = args[i];
        if (typeof value === "object") {
            value = JSON.stringify(value);
        }

        string = string.replace("{}", value);
    }

    return string;
}
392084
function(template, values, pattern) {
      pattern = pattern || /\{([^{}]*)\}/g;
      return template.replace(pattern, function(a, b) {
        var p = b.split('.'),
          r = values;
        try {
          for (var s in p) {
            if (p.hasOwnProperty(s)) {
              r = r[p[s]];
            }
          }
        } catch (e) {
          r = a;
        }
        return (typeof r === 'string' || typeof r === 'number') ? r : a;
      });
    }
1081362
function (fromString) {
                    var matches = fromString.match(/(\${.*?})/g);
                    if (matches != null) {
                        for (var i = 0; i < matches.length; i++) {
                            var val = values[matches[i].substring(2, matches[i].length - 1)] || "";
                            if (val != null) {
                                fromString = fromString.replace(matches[i], val);
                            }
                        }
                    }
                    return fromString;
                }
917536
function (val, model) {
            var name = this.name;
            if (!isUndefinedOrNull(val)) {
                this.__setValue(model, this._toModel(val));
            } else if (!model.isNew && isNull(val)) {
                model.__isChanged = true;
                this.__setValue(model, this._toModel(val));
                model[this.removeAssociationFlagName] = true;
            }
        }
1235435
function replaceSuperMethodCall(node, state, path, options) {
  // like super.foo()
  console.assert(node.type === "CallExpression");
  console.assert(node.callee.object.type === "Super");

  return funcCall(
            member(
              funcCall(
                member(options.functionNode, "_get"),
                replaceSuper(node.callee.object, state, path.concat(["callee", "object"]), options),
                literal(node.callee.property.value || node.callee.property.name),
                id("this")),
                "call"),
            id("this"), ...node.arguments);
}