Search in sources :

Example 16 with Configuration

use of freemarker.template.Configuration in project intellij-plugins by StepicOrg.

the class Templater method initConfig.

private static void initConfig() {
    config = new Configuration(Configuration.VERSION_2_3_23);
    config.setClassLoaderForTemplateLoading(Templater.class.getClassLoader(), "/templates");
}
Also used : Configuration(freemarker.template.Configuration)

Example 17 with Configuration

use of freemarker.template.Configuration in project zm-mailbox by Zimbra.

the class SoapApiChangeLog method writeChangelog.

private void writeChangelog() throws IOException, TemplateException {
    File templateDirFile = new File(templateDir, CHANGELOG_TEMPLATE_SUBDIR);
    Configuration config = new Configuration();
    config.setDirectoryForTemplateLoading(templateDirFile);
    config.setObjectWrapper(new BeansWrapper());
    fmTemplate = config.getTemplate(TEMPLATE_FILE);
    File of = new File(outputDir, OUTPUT_FILE);
    FileWriter out = new FileWriter(of);
    try {
        fmTemplate.process(changelogDataModel, out);
    } finally {
        try {
            out.close();
        } catch (Exception e) {
        // worst case scenario...clean-up quietly
        }
    }
}
Also used : Configuration(freemarker.template.Configuration) FileWriter(java.io.FileWriter) BeansWrapper(freemarker.ext.beans.BeansWrapper) File(java.io.File) TemplateException(freemarker.template.TemplateException) IOException(java.io.IOException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) JsonParseException(org.codehaus.jackson.JsonParseException) ParseException(org.apache.commons.cli.ParseException)

Example 18 with Configuration

use of freemarker.template.Configuration in project jangaroo-tools by CoreMedia.

the class ExmlComponentClassGenerator method generateClass.

public void generateClass(final ExmlModel model, final Writer output) throws IOException, TemplateException {
    Configuration cfg = new Configuration();
    cfg.setClassForTemplateLoading(ExmlComponentClassModel.class, "/");
    cfg.setObjectWrapper(new DefaultObjectWrapper());
    Template template = cfg.getTemplate("/net/jangaroo/exml/templates/exml_component_class.ftl");
    ExmlComponentClassModel exmlComponentClassModel = new ExmlComponentClassModel(model);
    Environment env = template.createProcessingEnvironment(exmlComponentClassModel, output);
    env.setOutputEncoding(Exmlc.OUTPUT_CHARSET);
    env.process();
}
Also used : ExmlConfiguration(net.jangaroo.exml.config.ExmlConfiguration) Configuration(freemarker.template.Configuration) DefaultObjectWrapper(freemarker.template.DefaultObjectWrapper) Environment(freemarker.core.Environment) Template(freemarker.template.Template)

Example 19 with Configuration

use of freemarker.template.Configuration in project jangaroo-tools by CoreMedia.

the class ExmlConfigClassGenerator method generateClass.

private static void generateClass(final ConfigClass configClass, final Writer output) throws IOException, TemplateException {
    if (configClass.getSuperClassName() == null) {
        throw new ExmlcException("Config class " + configClass.getFullName() + "'s super class name is null!");
    }
    Configuration cfg = new Configuration();
    cfg.setClassForTemplateLoading(ConfigClass.class, "/");
    cfg.setObjectWrapper(new DefaultObjectWrapper());
    Template template = cfg.getTemplate("/net/jangaroo/exml/templates/exml_config_class.ftl");
    Environment env = template.createProcessingEnvironment(configClass, output);
    env.setOutputEncoding(Exmlc.OUTPUT_CHARSET);
    env.process();
}
Also used : Configuration(freemarker.template.Configuration) ExmlcException(net.jangaroo.exml.api.ExmlcException) DefaultObjectWrapper(freemarker.template.DefaultObjectWrapper) Environment(freemarker.core.Environment) Template(freemarker.template.Template)

Example 20 with Configuration

use of freemarker.template.Configuration in project jangaroo-tools by CoreMedia.

the class ExmlConfigPackageXsdGenerator method generateXsdFile.

public void generateXsdFile(final Collection<ConfigClass> configClasses, String configClassPackage, final Writer output) throws IOException, TemplateException {
    ExmlConfigPackage suite = new ExmlConfigPackage(configClasses, configClassPackage);
    Configuration cfg = new Configuration();
    cfg.setClassForTemplateLoading(ExmlConfigPackage.class, "/");
    cfg.setObjectWrapper(new DefaultObjectWrapper());
    Template template = cfg.getTemplate("/net/jangaroo/exml/templates/exml_config_package_xsd.ftl");
    Environment env = template.createProcessingEnvironment(suite, output);
    env.setOutputEncoding(Exmlc.OUTPUT_CHARSET);
    env.process();
}
Also used : Configuration(freemarker.template.Configuration) DefaultObjectWrapper(freemarker.template.DefaultObjectWrapper) Environment(freemarker.core.Environment) Template(freemarker.template.Template)

Aggregations

Configuration (freemarker.template.Configuration)56 Template (freemarker.template.Template)30 Writer (java.io.Writer)17 IOException (java.io.IOException)14 StringWriter (java.io.StringWriter)14 File (java.io.File)13 HashMap (java.util.HashMap)11 DefaultObjectWrapper (freemarker.template.DefaultObjectWrapper)8 TemplateException (freemarker.template.TemplateException)7 OutputStreamWriter (java.io.OutputStreamWriter)7 StringTemplateLoader (freemarker.cache.StringTemplateLoader)5 ThirdEyeAnomalyConfiguration (com.linkedin.thirdeye.anomaly.ThirdEyeAnomalyConfiguration)4 ClassTemplateLoader (freemarker.cache.ClassTemplateLoader)4 FileTemplateLoader (freemarker.cache.FileTemplateLoader)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 FileWriter (java.io.FileWriter)4 StringReader (java.io.StringReader)4 ArrayList (java.util.ArrayList)4 MultiTemplateLoader (freemarker.cache.MultiTemplateLoader)3 TemplateLoader (freemarker.cache.TemplateLoader)3