private MailTemplateProvider() { configuration = new Configuration(Configuration.getVersion()); configuration.setClassForTemplateLoading(MailTemplateProvider.class, "/mail_templates"); configuration.setDefaultEncoding("UTF-8"); }
public static void checkVersionNotNullAndSupported(Version incompatibleImprovements) { NullArgumentException.check("incompatibleImprovements", incompatibleImprovements); int iciV = incompatibleImprovements.intValue(); if (iciV > Configuration.getVersion().intValue()) { throw new IllegalArgumentException("The FreeMarker version requested by \"incompatibleImprovements\" was " + incompatibleImprovements + ", but the installed FreeMarker version is only " + Configuration.getVersion() + ". You may need to upgrade FreeMarker in your project."); } if (iciV < VERSION_INT_2_3_0) { throw new IllegalArgumentException("\"incompatibleImprovements\" must be at least 2.3.0."); } }
public static void main(String[] args) { Version ver = Configuration.getVersion(); System.out.println(); System.out.print("Apache FreeMarker version "); System.out.print(ver); /* If the version number doesn't already contain the build date and it's known, print it: */ if (!ver.toString().endsWith("Z") && ver.getBuildDate() != null) { System.out.print(" (built on "); System.out.print(DateUtil.dateToISO8601String( ver.getBuildDate(), true, true, true, DateUtil.ACCURACY_SECONDS, DateUtil.UTC, new DateUtil.TrivialDateToISO8601CalendarFactory())); System.out.print(")"); } System.out.println(); if (ver.isGAECompliant() != null) { System.out.print("Google App Engine complian variant: "); System.out.println(ver.isGAECompliant().booleanValue() ? "Yes" : "No"); } } }
+ "you're using FreeMarker ").append(Configuration.getVersion()).append(".\n" + "The alphabetical list of built-ins:"); List names = new ArrayList(BUILT_INS_BY_NAME.keySet().size());
@Override public void configure(final Env env, final Config config, final Binder binder) throws TemplateException { Configuration freemarker = new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS); log.debug("Freemarker: {}", Configuration.getVersion()); freemarker.setSettings(properties(config)); freemarker.setTemplateLoader(new ClassTemplateLoader(getClass().getClassLoader(), prefix)); // cache if ("dev".equals(env.name()) || config.getString("freemarker.cache").isEmpty()) { // noop cache freemarker.setCacheStorage(NullCacheStorage.INSTANCE); } else { freemarker.setCacheStorage( new GuavaCacheStorage( CacheBuilder .from(config.getString("freemarker.cache")) .build())); } freemarker.setOutputFormat(HTMLOutputFormat.INSTANCE); if (configurer != null) { configurer.accept(freemarker, config); } binder.bind(Configuration.class).toInstance(freemarker); Engine engine = new Engine(freemarker, suffix, new XssDirective(env)); Multibinder.newSetBinder(binder, Renderer.class) .addBinding().toInstance(engine); }
} else { tip = "Help (latest version): http://freemarker.org/docs/ref_directive_alphaidx.html; " + "you're using FreeMarker " + Configuration.getVersion() + ".";
/** * @param config * @param startStep * @param fromVersion */ public InstallServlet(Properties config, String startStep, String fromVersion) { this.startStep = startStep; this.fromVersion = fromVersion; this.cmsUpgrader = new CmsUpgrader(config); this.freemarkerConfiguration = new Configuration(Configuration.getVersion()); freemarkerConfiguration.setClassForTemplateLoading(getClass(), "/initialization/template/"); freemarkerConfiguration.setDefaultEncoding("utf-8"); freemarkerConfiguration.setNumberFormat("#"); }
/** * @param config * @param startStep * @param fromVersion */ public InstallServlet(Properties config, String startStep, String fromVersion) { this.startStep = startStep; this.fromVersion = fromVersion; this.cmsUpgrader = new CmsUpgrader(config); this.freemarkerConfiguration = new Configuration(Configuration.getVersion()); freemarkerConfiguration.setClassForTemplateLoading(getClass(), "/initialization/template/"); freemarkerConfiguration.setDefaultEncoding("utf-8"); freemarkerConfiguration.setNumberFormat("#"); }
/** * */ public GetTemplateResultMethod() { configuration = new Configuration(Configuration.getVersion()); configuration.setDefaultEncoding(CommonConstants.DEFAULT_CHARSET_NAME); configuration.setTemplateUpdateDelayMilliseconds(0); configuration.setAPIBuiltinEnabled(false); configuration.setNewBuiltinClassResolver(TemplateClassResolver.ALLOWS_NOTHING_RESOLVER); configuration.setLogTemplateExceptions(false); }
/** * */ public GetTemplateResultMethod() { configuration = new Configuration(Configuration.getVersion()); configuration.setDefaultEncoding(CommonConstants.DEFAULT_CHARSET_NAME); configuration.setTemplateUpdateDelayMilliseconds(0); configuration.setAPIBuiltinEnabled(false); configuration.setNewBuiltinClassResolver(TemplateClassResolver.ALLOWS_NOTHING_RESOLVER); configuration.setLogTemplateExceptions(false); }
/** * @throws IOException * */ public SourceGenerator() throws IOException { config = new freemarker.template.Configuration(Configuration.getVersion()); config.setDirectoryForTemplateLoading(new File("src/test/resources/generator/")); config.setDefaultEncoding("utf-8"); }
@Autowired private void init(FreeMarkerConfigurer freeMarkerConfigurer, DirectiveComponent directiveComponent) throws IOException, TemplateModelException { Map<String, Object> freemarkerVariables = new HashMap<>(); adminConfiguration = freeMarkerConfigurer.getConfiguration(); for (Entry<String, AbstractTemplateDirective> entry : directiveComponent.getTemplateDirectiveMap().entrySet()) { freemarkerVariables.put(directivePrefix + entry.getKey(), entry.getValue()); } freemarkerVariables.putAll(directiveComponent.getMethodMap()); adminConfiguration.setAllSharedVariables(new SimpleHash(freemarkerVariables, adminConfiguration.getObjectWrapper())); webConfiguration = new Configuration(Configuration.getVersion()); File webFile = new File(siteComponent.getWebTemplateFilePath()); webFile.mkdirs(); webConfiguration.setDirectoryForTemplateLoading(webFile); copyConfig(adminConfiguration, webConfiguration); Map<String, Object> webFreemarkerVariables = new HashMap<>(freemarkerVariables); webFreemarkerVariables.put(TemplateCacheComponent.CONTENT_CACHE, new NoCacheDirective()); webConfiguration.setAllSharedVariables(new SimpleHash(webFreemarkerVariables, webConfiguration.getObjectWrapper())); taskConfiguration = new Configuration(Configuration.getVersion()); File taskFile = new File(siteComponent.getTaskTemplateFilePath()); taskFile.mkdirs(); taskConfiguration.setDirectoryForTemplateLoading(taskFile); copyConfig(adminConfiguration, taskConfiguration); for (Entry<String, AbstractTaskDirective> entry : directiveComponent.getTaskDirectiveMap().entrySet()) { freemarkerVariables.put(directivePrefix + entry.getKey(), entry.getValue()); } taskConfiguration.setAllSharedVariables(new SimpleHash(freemarkerVariables, taskConfiguration.getObjectWrapper())); }
@Autowired private void init(FreeMarkerConfigurer freeMarkerConfigurer, DirectiveComponent directiveComponent) throws IOException, TemplateModelException { Map<String, Object> freemarkerVariables = new HashMap<>(); adminConfiguration = freeMarkerConfigurer.getConfiguration(); for (Entry<String, AbstractTemplateDirective> entry : directiveComponent.getTemplateDirectiveMap().entrySet()) { freemarkerVariables.put(directivePrefix + entry.getKey(), entry.getValue()); } freemarkerVariables.putAll(directiveComponent.getMethodMap()); adminConfiguration.setAllSharedVariables(new SimpleHash(freemarkerVariables, adminConfiguration.getObjectWrapper())); webConfiguration = new Configuration(Configuration.getVersion()); File webFile = new File(siteComponent.getWebTemplateFilePath()); webFile.mkdirs(); webConfiguration.setDirectoryForTemplateLoading(webFile); copyConfig(adminConfiguration, webConfiguration); Map<String, Object> webFreemarkerVariables = new HashMap<>(freemarkerVariables); webFreemarkerVariables.put(TemplateCacheComponent.CONTENT_CACHE, new NoCacheDirective()); webConfiguration.setAllSharedVariables(new SimpleHash(webFreemarkerVariables, webConfiguration.getObjectWrapper())); taskConfiguration = new Configuration(Configuration.getVersion()); File taskFile = new File(siteComponent.getTaskTemplateFilePath()); taskFile.mkdirs(); taskConfiguration.setDirectoryForTemplateLoading(taskFile); copyConfig(adminConfiguration, taskConfiguration); for (Entry<String, AbstractTaskDirective> entry : directiveComponent.getTaskDirectiveMap().entrySet()) { freemarkerVariables.put(directivePrefix + entry.getKey(), entry.getValue()); } taskConfiguration.setAllSharedVariables(new SimpleHash(freemarkerVariables, taskConfiguration.getObjectWrapper())); }
Configuration.getVersion()));
/** * Returns the FreeMarker version used. * * @since 0.9.16 */ public static Version getFreeMarkerVersion() { return Configuration.getVersion(); }
private Template getTemplate(String name) throws IOException { Configuration cfg = new Configuration(Configuration.getVersion()); cfg.setTemplateLoader(new URLTemplateLoader() { @Override protected URL getURL(String name) { return SpringBootStarterMojo.class.getResource("/" + name); } }); cfg.setDefaultEncoding("UTF-8"); Template template = cfg.getTemplate(name); return template; }
public static void checkVersionNotNullAndSupported(Version incompatibleImprovements) { NullArgumentException.check("incompatibleImprovements", incompatibleImprovements); int iciV = incompatibleImprovements.intValue(); if (iciV > Configuration.getVersion().intValue()) { throw new IllegalArgumentException("The FreeMarker version requested by \"incompatibleImprovements\" was " + incompatibleImprovements + ", but the installed FreeMarker version is only " + Configuration.getVersion() + ". You may need to upgrade FreeMarker in your project."); } if (iciV < VERSION_INT_2_3_0) { throw new IllegalArgumentException("\"incompatibleImprovements\" must be at least 2.3.0."); } }
private static Configuration createConfiguration() { final Configuration cfg = new Configuration(Configuration.getVersion()); cfg.setClassForTemplateLoading(TemplateConfiguration.class, "/megamek/common/templates"); cfg.setDefaultEncoding("UTF-8"); cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); cfg.setLogTemplateExceptions(false); cfg.setWrapUncheckedExceptions(true); return cfg; } }
public StructTemplate() { this.configuration = new Configuration(Configuration.getVersion()); this.loader = new StringTemplateLoader(); this.configuration.setTemplateLoader(this.loader); this.configuration.setDefaultEncoding("UTF-8"); this.configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); this.configuration.setLogTemplateExceptions(false); this.configuration.setObjectWrapper(new ConnectObjectWrapper()); }
public Object exec(List list) throws TemplateModelException { if (list.size() < 1) { throw new TemplateModelException("The accessorOverridesAnother method must have the accessor as a parameter."); } TemplateModel from = (TemplateModel) list.get(0); Object unwrapped = new BeansWrapperBuilder(Configuration.getVersion()).build().unwrap(from); if (!(unwrapped instanceof Accessor)) { throw new TemplateModelException("The accessorOverridesAnother method must have the accessor as a parameter."); } return overridesAnother((Accessor) unwrapped); }