function substitute(template) {
  var variables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  return "".concat(template).replace(/(?:\\)?\[([^[\]]+)]/g, function (match, name) {
    if (match.charAt(0) === '\\') {
      return match.substr(1, match.length - 1);
    }

    return variables[name] === void 0 ? '' : variables[name];
  });
}
Substitute strings placed beetwen square brackets into value defined in `variables` object. String names defined in
square brackets must be the same as property name of `variables` object.

@param {String} template Template string.
@param {Object} variables Object which contains all available values which can be injected into template.
@returns {String}