public static String processTemplate(String text, Module module,
Environment environment) {
text = processTemplate(text);
Map<String, String> replacements = new HashMap<String, String>();
Site site = module.getSite();
// ${site.root}
StringBuffer siteRootReplacement = new StringBuffer();
siteRootReplacement.append(site.getHostname(environment).toExternalForm());
siteRootReplacement.append("/weblounge-sites/").append(site.getIdentifier());
replacements.put("file://\\$\\{site.root\\}", siteRootReplacement.toString());
// ${module.root}
StringBuffer moduleRootReplacement = new StringBuffer(siteRootReplacement);
moduleRootReplacement.append("/modules/").append(module.getIdentifier());
replacements.put("file://\\$\\{module.root\\}", moduleRootReplacement.toString());
// Site options
for (String option : site.getOptionNames()) {
String value = site.getOptionValue(option);
replacements.put("\\$\\{" + option + "\\}", value);
}
// Replace with whatever is available
for (Map.Entry<String, String> entry : replacements.entrySet()) {