Replaces variables in the value. The variable format is %var.

@private
@param {String} value Value to replace variables in.
@param {Object} vars Name/value array with variables to replace.
@return {String} New value with replaced variables.
514171
function replaceVars(value, vars) {
        if (typeof value != "string") {
          value = value(vars);
        } else if (vars) {
          value = value.replace(/%(\w+)/g, function (str, name) {
            return vars[name] || str;
          });
        }

        return value;
      }
316116
def _replace_global_vars(xs, global_vars):
    
    if isinstance(xs, (list, tuple)):
        return [_replace_global_vars(x) for x in xs]
    elif isinstance(xs, dict):
        final = {}
        for k, v in xs.items():
            if isinstance(v, six.string_types) and v in global_vars:
                v = global_vars[v]
            final[k] = v
        return final
    else:
        return xs
434416
public static String fixPropertyValue(String value) {
		// replace with predefined varialebls
		value = value.replaceAll("\\{jk.appname\\}", JK.getAppName());
		return value;
	}
982199
function replaceVariableTokens(pattern, next) {
        var filenames = config.timemarks.map(function(t, i) {
          return pattern
            .replace(/%s/g, utils.timemarkToSeconds(t))
            .replace(/%(0*)i/g, function(match, padding) {
              var idx = '' + (i + 1);
              return padding.substr(0, Math.max(0, padding.length + 1 - idx.length)) + idx;
            });
        });

        self.emit('filenames', filenames);
        next(null, filenames);
      }
583600
public JsStatement var(String variable)
	{
		JsStatement statement = new JsStatement();
		statements.add(statement);
		return statement.append(variable);
	}
1229872
function(str, varName, varValue){
    if(str === varName) return varValue;
    var strType = typeof varValue === "string", ln = str.length;
    var patt = (strType || (str.indexOf('{{') !== 0 || str.indexOf('}}') !== (ln-2))) ? varName : '"'+varName+'"';
    var rValue = strType ? varValue : JSON.stringify(varValue);
    return str.replace(patt,function(){ return rValue; });
  }
767566
def set_default(self, name, value):
        
        if self.vars is None:
            self.vars = {}
        if name not in self.vars:
            self.vars[name] = value
50714
public static boolean isVariableReplacementPattern(final String value) {
    final Matcher matcher = VARIABLE_REPLACEMENT_PATTERN.matcher(value);
    return matcher.matches();
  }
411944
def _replace_variables(data, variables):
    """"""
    formatter = string.Formatter()
    return [formatter.vformat(item, [], variables) for item in data]
1273436
def set_variable(self, name, value):
        
        if value is None:
            # Unset the variable.
            if name in self._var:
                del self._var[name]
        self._var[name] = value
695969
@Override
	protected void putVariables(Map<String, String> variables) {
		variables.put(ScopeFormat.asVariable(this.key), value);
	}
39515
def substitute_filename(fn, variables):
    
    for var, value in variables.items():
        fn = fn.replace('+%s+' % var, str(value))
    return fn
852401
function transformVariables(source, dest) {
        var xformed, arrayVals;

        if (dest === undefined) {
            xformed = {};
        }
        else {
            xformed = dest;
        }

        $.each(source, function(prop, val) {
            if (val instanceof $) {
                xformed[prop] = val[0];
            }
            else if ($.isPlainObject(val)) {
                xformed[prop] = {};
                transformVariables(val, xformed[prop]);
            }
            else if ($.isArray(val)) {
                arrayVals = [];
                $.each(val, function(idx, arrayVal) {
                    if (arrayVal instanceof $) {
                        $.merge(arrayVals, arrayVal);
                    }
                    else {
                        arrayVals.push(arrayVal);
                    }
                });
                xformed[prop] = arrayVals;
            }
            else {
                xformed[prop] = val;
            }
        });

        if (dest === undefined) {
            return xformed;
        }
    }
991409
function replaceInString(string, variables) {
    const model = createModel(string);
    let offset = 0;
    let output = '';

    for (let i = 0, il = model.variables.length; i < il; i++) {
        const v = model.variables[i];
        let value = v.name in variables ? variables[v.name] : v.name;
        if (typeof value === 'function') {
            value = value(model.string, v, offset + v.location);
        }

        output += model.string.slice(offset, v.location) + value;
        offset = v.location + v.length;
    }

    return output + model.string.slice(offset);
}
1110206
function VarCommand(value, engine) {
        var match = value.match(/^\s*([a-z0-9_]+)\s*=([\s\S]*)$/i);
        if (!match) {
            throw new Error('Invalid ' + this.type + ' syntax: ' + value);
        }

        this.name = match[1];
        this.expr = match[2];
        Command.call(this, value, engine);
        this.cloneProps = ['name', 'expr'];
    }
976172
function render(template, vars) {
    var rendered = template;

    for (var key in vars) {
        if (vars.hasOwnProperty(key)) {
            var val = vars[key];
            var regExpString = '\\{' + key + '\\}';
            var regExp = new RegExp(regExpString, 'g');

            rendered = rendered.replace(regExp, val);
        }
    }

    return rendered;
}
1167861
public static void setVariableWithSingleQuotationMarks(final String variablename,
		final Object object, final Map<String, Object> variables)
	{
		if (object != null)
		{
			variables.put(variablename, "'" + object + "'");
		}
		else
		{
			variables.put(variablename, "null");
		}
	}