use of freemarker.template.Template in project bamboobsc by billchen198318.
the class CodeGeneratorUtil method generatorProcess.
private static void generatorProcess(String packageName, String headName, String templateFilePath) throws Exception {
Configuration cfg = new Configuration(Configuration.VERSION_2_3_21);
cfg.setClassForTemplateLoading(CodeGeneratorUtil.class, "");
Template template = cfg.getTemplate(templateFilePath, "utf-8");
Map<String, Object> params = new HashMap<String, Object>();
params.put("packageName", packageName);
params.put("headName", headName);
params.put("headNameSmall", headName.substring(0, 1).toLowerCase() + headName.substring(1, headName.length()));
String outDir = System.getProperty("user.dir") + "/out";
String outFilePath = outDir + "/" + getOutFileFootName(headName, templateFilePath);
Writer file = new FileWriter(new File(outFilePath));
template.process(params, file);
file.flush();
file.close();
}
use of freemarker.template.Template in project opennms by OpenNMS.
the class NavBarController method afterPropertiesSet.
/**
* <p>afterPropertiesSet</p>
* @throws IOException
*/
@Override
public void afterPropertiesSet() throws IOException {
Assert.state(m_navBarItems != null, "navBarItems property has not been set");
// Initialize the Freemarker engine and fetch our template
Configuration cfg = new Configuration(Configuration.VERSION_2_3_21);
cfg.setDefaultEncoding(StandardCharsets.UTF_8.name());
cfg.setClassForTemplateLoading(NavBarController.class, "");
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
Template template = cfg.getTemplate("navbar.ftl");
m_view = new FreemarkerView(template);
}
use of freemarker.template.Template in project bamboobsc by billchen198318.
the class ComponentResourceUtils method generatorResource.
public static String generatorResource(Class<?> c, String type, String metaInfFile, Map<String, Object> params) throws Exception {
StringTemplateLoader templateLoader = new StringTemplateLoader();
templateLoader.putTemplate("resourceTemplate", getResourceSrc(c, type, metaInfFile));
Configuration cfg = new Configuration(Configuration.VERSION_2_3_21);
cfg.setTemplateLoader(templateLoader);
Template template = cfg.getTemplate("resourceTemplate", Constants.BASE_ENCODING);
Writer out = new StringWriter();
template.process(params, out);
return out.toString();
}
use of freemarker.template.Template in project hub-alert by blackducksoftware.
the class ChannelFreemarkerTemplatingService method getResolvedTemplate.
public String getResolvedTemplate(final Map<String, Object> model, final String templateName) throws TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, TemplateException {
final StringWriter stringWriter = new StringWriter();
final Template template = configuration.getTemplate(templateName);
template.process(model, stringWriter);
return stringWriter.toString();
}
use of freemarker.template.Template in project hub-alert by blackducksoftware.
the class ChannelFreemarkerTemplatingService method getResolvedSubjectLine.
public String getResolvedSubjectLine(final Map<String, Object> model) throws IOException, TemplateException {
String subjectLine = (String) model.get(EmailProperties.TEMPLATE_KEY_SUBJECT_LINE);
if (StringUtils.isBlank(subjectLine)) {
subjectLine = "Default Subject Line - please define one";
}
final Template subjectLineTemplate = new Template("subjectLineTemplate", subjectLine, configuration);
final StringWriter stringWriter = new StringWriter();
subjectLineTemplate.process(model, stringWriter);
return stringWriter.toString();
}
Aggregations