Search in sources :

Example 1 with SoftCacheStorage

use of freemarker.cache.SoftCacheStorage in project be5 by DevelopmentOnTheEdge.

the class FreemarkerUtils method getConfiguration.

public static Configuration getConfiguration(Project project) {
    Configuration config = (Configuration) configTemplate.clone();
    config.setCacheStorage(new SoftCacheStorage());
    try {
        config.setSharedVariable("project", project);
    } catch (TemplateModelException e) {
        throw new RuntimeException("Unexpected error: " + e, e);
    }
    FreemarkerScript macroCollection = project.getMacroCollection().optScript(FreemarkerCatalog.MAIN_MACRO_LIBRARY);
    if (macroCollection != null) {
        config.addAutoInclude(macroCollection.getCompletePath().toString());
    }
    for (Module module : project.getModules()) {
        FreemarkerCatalog collection = module.getMacroCollection();
        if (collection != null) {
            FreemarkerScript script = collection.optScript(FreemarkerCatalog.MAIN_MACRO_LIBRARY);
            if (script != null) {
                config.addAutoInclude(script.getCompletePath().toString());
            }
        }
    }
    config.setTemplateLoader(new ProjectTemplateLoader(project));
    return config;
}
Also used : TemplateModelException(freemarker.template.TemplateModelException) Configuration(freemarker.template.Configuration) SoftCacheStorage(freemarker.cache.SoftCacheStorage) FreemarkerCatalog(com.developmentontheedge.be5.metadata.model.FreemarkerCatalog) FreemarkerScript(com.developmentontheedge.be5.metadata.model.FreemarkerScript) Module(com.developmentontheedge.be5.metadata.model.Module)

Aggregations

FreemarkerCatalog (com.developmentontheedge.be5.metadata.model.FreemarkerCatalog)1 FreemarkerScript (com.developmentontheedge.be5.metadata.model.FreemarkerScript)1 Module (com.developmentontheedge.be5.metadata.model.Module)1 SoftCacheStorage (freemarker.cache.SoftCacheStorage)1 Configuration (freemarker.template.Configuration)1 TemplateModelException (freemarker.template.TemplateModelException)1