Search in sources :

Example 96 with Configuration

use of freemarker.template.Configuration in project freemarker by apache.

the class EncodingOverrideTest method createConfig.

private Configuration createConfig(String charset) {
    Configuration cfg = new Configuration(Configuration.VERSION_2_3_21);
    cfg.setClassForTemplateLoading(EncodingOverrideTest.class, "");
    cfg.setDefaultEncoding(charset);
    return cfg;
}
Also used : Configuration(freemarker.template.Configuration)

Example 97 with Configuration

use of freemarker.template.Configuration in project freemarker by apache.

the class EnvironmentCustomStateTest method test.

@Test
public void test() throws Exception {
    Configuration cfg = new Configuration(Configuration.VERSION_2_3_24);
    Template t = new Template(null, "", cfg);
    Environment env = t.createProcessingEnvironment(null, null);
    assertNull(env.getCustomState(KEY_1));
    assertNull(env.getCustomState(KEY_2));
    env.setCustomState(KEY_1, "a");
    env.setCustomState(KEY_2, "b");
    assertEquals("a", env.getCustomState(KEY_1));
    assertEquals("b", env.getCustomState(KEY_2));
    env.setCustomState(KEY_1, "c");
    env.setCustomState(KEY_2, null);
    assertEquals("c", env.getCustomState(KEY_1));
    assertNull(env.getCustomState(KEY_2));
}
Also used : Configuration(freemarker.template.Configuration) Template(freemarker.template.Template) Test(org.junit.Test)

Example 98 with Configuration

use of freemarker.template.Configuration in project freemarker by apache.

the class GetOptionalTemplateTest method createConfiguration.

@Override
protected Configuration createConfiguration() throws Exception {
    Configuration cfg = super.createConfiguration();
    cfg.setTemplateLoader(new MultiTemplateLoader(new TemplateLoader[] { new StringTemplateLoader(), byteArrayTemplateLoader }));
    return cfg;
}
Also used : MultiTemplateLoader(freemarker.cache.MultiTemplateLoader) StringTemplateLoader(freemarker.cache.StringTemplateLoader) Configuration(freemarker.template.Configuration) TemplateLoader(freemarker.cache.TemplateLoader) ByteArrayTemplateLoader(freemarker.cache.ByteArrayTemplateLoader) StringTemplateLoader(freemarker.cache.StringTemplateLoader) MultiTemplateLoader(freemarker.cache.MultiTemplateLoader)

Example 99 with Configuration

use of freemarker.template.Configuration in project freemarker by apache.

the class CanonicalFormTest method assertCanonicalFormOf.

private void assertCanonicalFormOf(String ftlFileName) throws TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException {
    Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
    cfg.setTemplateLoader(new CopyrightCommentRemoverTemplateLoader(new ClassTemplateLoader(CanonicalFormTest.class, "")));
    StringWriter sw = new StringWriter();
    cfg.getTemplate(ftlFileName).dump(sw);
    assertExpectedFileEqualsString(ftlFileName + ".out", sw.toString());
}
Also used : CopyrightCommentRemoverTemplateLoader(freemarker.test.CopyrightCommentRemoverTemplateLoader) Configuration(freemarker.template.Configuration) StringWriter(java.io.StringWriter) ClassTemplateLoader(freemarker.cache.ClassTemplateLoader)

Example 100 with Configuration

use of freemarker.template.Configuration in project freemarker by apache.

the class CapturingAssignmentTest method createConfiguration.

@Override
protected Configuration createConfiguration() throws Exception {
    Configuration cfg = super.createConfiguration();
    cfg.setTemplateLoader(new StringTemplateLoader());
    return cfg;
}
Also used : StringTemplateLoader(freemarker.cache.StringTemplateLoader) Configuration(freemarker.template.Configuration)

Aggregations

Configuration (freemarker.template.Configuration)282 Template (freemarker.template.Template)106 Test (org.junit.Test)86 TemplateTest (freemarker.test.TemplateTest)52 HashMap (java.util.HashMap)51 IOException (java.io.IOException)41 StringWriter (java.io.StringWriter)39 File (java.io.File)33 TemplateException (freemarker.template.TemplateException)29 Writer (java.io.Writer)27 ClassTemplateLoader (freemarker.cache.ClassTemplateLoader)19 ConditionalTemplateConfigurationFactory (freemarker.cache.ConditionalTemplateConfigurationFactory)19 StringTemplateLoader (freemarker.cache.StringTemplateLoader)18 DefaultObjectWrapper (freemarker.template.DefaultObjectWrapper)18 FileNameGlobMatcher (freemarker.cache.FileNameGlobMatcher)17 TemplateLoader (freemarker.cache.TemplateLoader)16 MultiTemplateLoader (freemarker.cache.MultiTemplateLoader)15 FileWriter (java.io.FileWriter)13 ArrayList (java.util.ArrayList)13 User (org.vcell.util.document.User)13