Interface | Description |
---|---|
IOutputDirectiveFactory |
IOutputDirectiveFactory
用于定制自定义输出指令,替换系统默认输出指令,满足个性化需求
用法:
1:定义 MyOutput
public class MyOutput extends Output {
public MyOutput(ExprList exprList) {
super(exprList);
}
public void exec(Env env, Scope scope, Writer writer) {
write(writer, exprList.eval(scope));
}
}
2:定义 MyOutputDirectiveFactory
public class MyOutputDirectiveFactory implements IOutputDirectiveFactory {
public Output getOutputDirective(ExprList exprList) {
return new MyOutput(exprList);
}
}
3:配置
engine.setOutputDirectiveFactory(new MyOutputDirectiveFactory())
|
Class | Description |
---|---|
Directive |
Directive 供用户继承并扩展自定义指令,具体用法可以参考
com.jfinal.template.ext.directive 包下面的例子
|
Engine |
Engine
Example:
Engine.use().getTemplate(fileName).render(...);
Engine.use().getTemplate(fileName).renderToString(...);
|
EngineConfig |
EngineConfig
|
Env |
Env
1:解析时存放 #define 定义的模板函数
2:运行时提供 #define 定义的模板函数
3:每个 Template 对象持有一个 Env 对象
|
OutputDirectiveFactory |
OutputDirectiveFactory
|
Template |
Template
用法:
Template template = Engine.use().getTemplate(...);
template.render(data, writer);
template.renderToString(data);
|
Exception | Description |
---|---|
TemplateException |
Template runtime exception
|
Copyright © 2018. All rights reserved.