code: function swap(str, swaps) {
    return str.replace(/\{[^}]*\}/g, function(name) {
      name = name.slice(1, -1);
      if (swaps == null) {
        console.log('Missing swaps while looking up \'' + name + '\'');
        return '';
      }
      var replacement = swaps[name];
      if (replacement == null) {
        console.log('Can\'t find \'' + name + '\' in ' + JSON.stringify(swaps));
        replacement = '';
      }
      return replacement;
    });
  }
docs: Helper function to process swaps.
  For example:
  swap('the {subject} {verb} {preposition} the {object}', {
  subject: 'cat', verb: 'sat', preposition: 'on', object: 'mat'
  });
  Returns 'the cat sat on the mat'.
  @param str The string containing parts delimited by { and } to be replaced
  @param swaps Lookup map containing the replacement strings