- /**
- * The poor man's template package.
- * Provide a template and a map of terms to build the result with the
- * terms expanded into the template. Terms in the template should
- * appear surrounded with dollar signs. For example, if $MYTERM$
- * appears in the template, it will be replaced by the value into the
- * terms map with the key MYTERM (if it exists in the map).
- * @param template The template string.
- * @param terms A map of key/value terms.
- * @return The string expanded from the template and terms.
- */
- public static String expandTemplate(String template, Map<String,String> terms)
- {
- String text = template;
- for (String key : terms.keySet())
- {
- text = text.replaceAll("\\$" + key + "\\$",
- Util.quote(terms.get(key)));
- }
- return text;
- }
+ /**
+ * The poor man's template package.
+ * Provide a template and a map of terms to build the result with the
+ * terms expanded into the template. Terms in the template should
+ * appear surrounded with dollar signs. For example, if $MYTERM$
+ * appears in the template, it will be replaced by the value into the
+ * terms map with the key MYTERM (if it exists in the map).
+ * @param template The template string.
+ * @param terms A map of key/value terms.
+ * @return The string expanded from the template and terms.
+ */
+ public static String expandTemplate(String template, Map<String,String> terms)
+ {
+ String text = template;
+ for (String key : terms.keySet())
+ {
+ text = text.replaceAll("\\$" + key + "\\$", Util.escape(terms.get(key)));
+ }
+ return text;
+ }