lib/templateProcessor.js
function processCondition(template, variables, matcher) {
  // eslint-disable-next-line no-constant-condition
  while (true) {
    let matchedCondition = template.match(matcher);
    if (!matchedCondition) {
      break;
    }

    let fragment = matchedCondition[0];
    let conditionCode = matchedCondition[1];

    let testResult = evaluateCondition(conditionCode, variables);
    let replaceWith = testResult
      ? matchedCondition[2]
      : matchedCondition[3] || '';

    template = template.replace(fragment, replaceWith);
  }

  return template;
}
function processCondition(template, variables, matcher) {
  // eslint-disable-next-line no-constant-condition
  while (true) {
    let matchedCondition = template.match(matcher);
    if (!matchedCondition) {
      break;
    }

    let fragment = matchedCondition[0];
    let conditionCode = matchedCondition[1];

    let testResult = evaluateCondition(conditionCode, variables);
    let replaceWith = testResult
      ? matchedCondition[2]
      : matchedCondition[3] || '';

    template = template.replace(fragment, replaceWith);
  }

  return template;
}
Processes the conditions within the provided template using the provided
condition matcher regexp.

@param {string} template The template to process.
@param {Object<string, *>} variables The variables that should be available
to the predicate expressions in the conditions.
@param {RegExp} matcher The regexp to use to match the conditions in the
template.
@return {string} Processed template.