Search in sources :

Example 1 with ReplaceParamTemplateMethod

use of io.leopard.web.freemarker.template.ReplaceParamTemplateMethod in project leopard by tanhaichao.

the class MyJettyView method getVariables.

@Override
public List<TemplateVariable> getVariables() {
    List<TemplateVariable> list = new ArrayList<TemplateVariable>();
    list.add(new TimeTemplateMethod());
    list.add(new BodyTemplateDirective());
    list.add(new ServerInfoTemplateDirective());
    list.add(new ReplaceParamTemplateMethod());
    list.add(new ButtonAjaxTemplateDirective());
    return list;
}
Also used : ButtonAjaxTemplateDirective(io.leopard.web.freemarker.template.ajax.ButtonAjaxTemplateDirective) ArrayList(java.util.ArrayList) TemplateVariable(io.leopard.web.freemarker.TemplateVariable) TimeTemplateMethod(io.leopard.web.freemarker.template.TimeTemplateMethod) BodyTemplateDirective(io.leopard.web.freemarker.template.BodyTemplateDirective) ReplaceParamTemplateMethod(io.leopard.web.freemarker.template.ReplaceParamTemplateMethod)

Example 2 with ReplaceParamTemplateMethod

use of io.leopard.web.freemarker.template.ReplaceParamTemplateMethod in project leopard by tanhaichao.

the class TopnbView method getVariables.

@Override
public List<TemplateVariable> getVariables() {
    List<TemplateVariable> list = new ArrayList<TemplateVariable>();
    list.add(new TimeTemplateMethod());
    list.add(new AvgTimeTemplateMethod());
    list.add(new BodyTemplateDirective());
    list.add(new MenuTemplateDirective());
    list.add(new ServerInfoTemplateDirective());
    list.add(new ReplaceParamTemplateMethod());
    return list;
}
Also used : ArrayList(java.util.ArrayList) TemplateVariable(io.leopard.web.freemarker.TemplateVariable) TimeTemplateMethod(io.leopard.web.freemarker.template.TimeTemplateMethod) BodyTemplateDirective(io.leopard.web.freemarker.template.BodyTemplateDirective) ReplaceParamTemplateMethod(io.leopard.web.freemarker.template.ReplaceParamTemplateMethod)

Example 3 with ReplaceParamTemplateMethod

use of io.leopard.web.freemarker.template.ReplaceParamTemplateMethod in project leopard by tanhaichao.

the class FreeMarkerUtil method getFreeMarkerConfigurer.

protected static FreeMarkerConfigurer getFreeMarkerConfigurer(ApplicationContext applicationContext, String templateLoaderPath) {
    Map<String, Object> freemarkerVariables = new HashMap<String, Object>();
    freemarkerVariables.put("xml_escape", "fmXmlEscape");
    freemarkerVariables.put("replaceParam", new ReplaceParamTemplateMethod());
    freemarkerVariables.put("timeAgo", new TimeAgoTemplateMethod());
    freemarkerVariables.putAll(listTemplateMethod(applicationContext));
    Properties freemarkerSettings = new Properties();
    freemarkerSettings.put("template_update_delay", "1");
    freemarkerSettings.put("defaultEncoding", "UTF-8");
    FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
    configurer.setTemplateLoaderPath(templateLoaderPath);
    configurer.setFreemarkerVariables(freemarkerVariables);
    configurer.setFreemarkerSettings(freemarkerSettings);
    try {
        configurer.afterPropertiesSet();
    } catch (IOException e) {
        throw new RuntimeException(e.getMessage(), e);
    } catch (TemplateException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
    return configurer;
}
Also used : HashMap(java.util.HashMap) TemplateException(freemarker.template.TemplateException) IOException(java.io.IOException) TimeAgoTemplateMethod(io.leopard.web.freemarker.template.TimeAgoTemplateMethod) Properties(java.util.Properties) ReplaceParamTemplateMethod(io.leopard.web.freemarker.template.ReplaceParamTemplateMethod) FreeMarkerConfigurer(org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer)

Aggregations

ReplaceParamTemplateMethod (io.leopard.web.freemarker.template.ReplaceParamTemplateMethod)3 TemplateVariable (io.leopard.web.freemarker.TemplateVariable)2 BodyTemplateDirective (io.leopard.web.freemarker.template.BodyTemplateDirective)2 TimeTemplateMethod (io.leopard.web.freemarker.template.TimeTemplateMethod)2 ArrayList (java.util.ArrayList)2 TemplateException (freemarker.template.TemplateException)1 TimeAgoTemplateMethod (io.leopard.web.freemarker.template.TimeAgoTemplateMethod)1 ButtonAjaxTemplateDirective (io.leopard.web.freemarker.template.ajax.ButtonAjaxTemplateDirective)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 FreeMarkerConfigurer (org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer)1