Java Code Examples for freemarker.template.Configuration#setSetting()

The following examples show how to use freemarker.template.Configuration#setSetting() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Freemarker.java    From freeacs with MIT License 6 votes vote down vote up
/**
 * Inits the freemarker.
 *
 * @return the configuration
 */
public static Configuration initFreemarker() {
  try {
    Configuration config = new Configuration();
    config.setTemplateLoader(new ClassTemplateLoader(Freemarker.class, "/templates"));
    config.setTemplateUpdateDelay(0);
    config.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
    config.setObjectWrapper(ObjectWrapper.BEANS_WRAPPER);
    config.setDefaultEncoding("ISO-8859-1");
    config.setOutputEncoding("ISO-8859-1");
    config.setNumberFormat("0");
    config.setSetting("url_escaping_charset", "ISO-8859-1");
    config.setLocale(Locale.ENGLISH);
    setAutoImport(config);
    setSharedVariables(config);
    return config;
  } catch (Throwable e) {
    throw new RuntimeException("Could not initialise Freemarker configuration", e);
  }
}
 
Example 2
Source File: ClinicalNoteExporter.java    From synthea with Apache License 2.0 6 votes vote down vote up
private static Configuration templateConfiguration() {
  Configuration configuration = new Configuration(Configuration.VERSION_2_3_26);
  configuration.setDefaultEncoding("UTF-8");
  configuration.setLogTemplateExceptions(false);
  try {
    configuration.setSetting("object_wrapper",
        "DefaultObjectWrapper(2.3.26, forceLegacyNonListCollections=false, "
            + "iterableSupport=true, exposeFields=true)");
  } catch (TemplateException e) {
    e.printStackTrace();
  }
  configuration.setAPIBuiltinEnabled(true);
  configuration.setClassLoaderForTemplateLoading(ClassLoader.getSystemClassLoader(),
      "templates/notes");
  return configuration;
}
 
Example 3
Source File: CCDAExporter.java    From synthea with Apache License 2.0 6 votes vote down vote up
private static Configuration templateConfiguration() {
  Configuration configuration = new Configuration(Configuration.VERSION_2_3_26);
  configuration.setDefaultEncoding("UTF-8");
  configuration.setLogTemplateExceptions(false);
  try {
    configuration.setSetting("object_wrapper",
        "DefaultObjectWrapper(2.3.26, forceLegacyNonListCollections=false, "
            + "iterableSupport=true, exposeFields=true)");
  } catch (TemplateException e) {
    e.printStackTrace();
  }
  configuration.setAPIBuiltinEnabled(true);
  configuration.setClassLoaderForTemplateLoading(ClassLoader.getSystemClassLoader(),
      "templates/ccda");
  return configuration;
}
 
Example 4
Source File: PluginFreeMarkerConfigurer.java    From onetwo with Apache License 2.0 4 votes vote down vote up
protected void postProcessConfiguration(Configuration config) throws IOException, TemplateException {
	config.setObjectWrapper(INSTANCE);
	config.setSetting("classic_compatible", "true");
	//默认不格式化数字
	config.setNumberFormat("#");
}