code: public static String injectVariables(String template, Map<String, String> variables)
    {
      VariablesWriter writer = new VariablesWriter(variables);
      try {
        Files.copy(new StringReader(template), writer);
      }
      catch(IOException e) {
        log.error(e);
      }
      return writer.toString();
    }
docs: Inject string values into variables from a given template string. Template uses de facto standard variable
  notation, <code>${variable-name}</code>, where name is the key from given variables hash. It is legal for a
  variable to be declared into template but be missing from variables hash, in which case variable from template is
  left unchanged.
  
  @param template source string template,
  @param variables string variables hash.
  @return resulting string with variables replaced.