Search in sources :

Example 1 with HTMLTemplateBuilder

use of core.framework.impl.template.HTMLTemplateBuilder in project core-ng-project by neowu.

the class HTMLTemplateEngine method add.

private void add(TemplateSource source, Class<?> modelClass) {
    StopWatch watch = new StopWatch();
    String name = source.name();
    try {
        HTMLTemplate previous = templates.putIfAbsent(name, new HTMLTemplateBuilder(source, modelClass).build());
        if (previous != null)
            throw Exceptions.error("template is already added, name={}", name);
    } finally {
        logger.info("add, name={}, modelClass={}, elapsedTime={}", name, modelClass.getCanonicalName(), watch.elapsedTime());
    }
}
Also used : HTMLTemplateBuilder(core.framework.impl.template.HTMLTemplateBuilder) HTMLTemplate(core.framework.impl.template.HTMLTemplate) StopWatch(core.framework.util.StopWatch)

Example 2 with HTMLTemplateBuilder

use of core.framework.impl.template.HTMLTemplateBuilder in project core-ng-project by neowu.

the class TemplateManager method load.

private Map<String, HTMLTemplate> load(String templatePath, Class<?> modelClass) {
    HTMLTemplateBuilder builder = new HTMLTemplateBuilder(new FileTemplateSource(webDirectory.root(), templatePath), modelClass);
    builder.cdn = cdnManager;
    Map<String, HTMLTemplate> templates = Maps.newHashMap();
    for (String language : message.languages) {
        builder.message = key -> message.get(key, language);
        HTMLTemplate htmlTemplate = builder.build();
        templates.put(language, htmlTemplate);
    }
    return templates;
}
Also used : FileTemplateSource(core.framework.impl.template.source.FileTemplateSource) HTMLTemplateBuilder(core.framework.impl.template.HTMLTemplateBuilder) HTMLTemplate(core.framework.impl.template.HTMLTemplate)

Aggregations

HTMLTemplate (core.framework.impl.template.HTMLTemplate)2 HTMLTemplateBuilder (core.framework.impl.template.HTMLTemplateBuilder)2 FileTemplateSource (core.framework.impl.template.source.FileTemplateSource)1 StopWatch (core.framework.util.StopWatch)1