Package | Description |
---|---|
com.jfinal.kit | |
com.jfinal.plugin.activerecord.sql | |
com.jfinal.template | |
com.jfinal.template.ext.directive | |
com.jfinal.template.stat.ast |
Modifier and Type | Class and Description |
---|---|
static class |
ElKit.InnerEvalDirective |
Modifier and Type | Class and Description |
---|---|
class |
NameSpaceDirective
NameSpaceDirective
|
class |
ParaDirective
#para 指令用于在 sql 模板中根据参数名生成问号占位以及查询参数
|
class |
SqlDirective
SqlDirective
|
Modifier and Type | Class and Description |
---|---|
class |
Directive
Directive 供用户继承并扩展自定义指令,具体用法可以参考
com.jfinal.template.ext.directive 包下面的例子
|
Modifier and Type | Field and Description |
---|---|
protected Stat |
Directive.stat
具有 #end 结束符的指令内部嵌套的所有内容,调用 stat.exec(env, scope, writer)
即可执行指令内部嵌入所有指令与表达式,如果指令没有 #end 结束符,该属性无效
|
Modifier and Type | Method and Description |
---|---|
void |
Directive.setStat(Stat stat)
指令被解析时注入指令 body 内容,仅对于具有 #end 结束符的指令有效
|
Constructor and Description |
---|
Template(Env env,
Stat ast) |
Modifier and Type | Class and Description |
---|---|
class |
DateDirective
#date 日期格式化输出指令
三种用法:
1:#date(createAt) 用默认 datePattern 配置,输出 createAt 变量中的日期值
2:#date(createAt, "yyyy-MM-dd HH:mm:ss") 用第二个参数指定的 datePattern,输出 createAt 变量中的日期值
3:#date() 用默认 datePattern 配置,输出 “当前” 日期值
注意:
1:#date 指令中的参数可以是变量,例如:#date(d, p) 中的 d 与 p 可以全都是变量
2:默认 datePattern 可通过 Engine.setDatePattern(...) 进行配置
|
class |
EscapeDirective
Escape 对字符串进行转义
用法:
#escape(value)
|
class |
NowDirective
输出当前时间,默认考虑是输出时间,给 pattern 输出可能是 Date、DateTime、Timestamp
带 String 参数,表示 pattern
|
class |
NumberDirective
#number 数字格式化输出指令
两种用法:
1:#number(n) 用默认 pattern 输出变量中的值
2:#number(n, "#.##") 用第二个参数指定的 pattern 输出变量中的值
注意:
1:pattern 的使用与 java.text.DecimalFormat 的完全一样
在拿不定主意的时候可以在搜索引擎中搜索关键字:DecimalFormat
2:#number 指令中的参数可以是变量,例如:#number(n, p) 中的 n 与 p 可以全都是变量
|
class |
RandomDirective
输出 int 型随机数
|
class |
RenderDirective
#render 指令用于动态渲染子模板,作为 include 指令的补充
|
class |
StringDirective
#string 指令方便定义大量的多行文本变量,这个是 java 语言中极为需要的功能
定义:
#string(name)
在此是大量的字符串
#end
使用:
#(name)
|
Modifier and Type | Class and Description |
---|---|
class |
Break
Break
java 中 break、continue 可出现在 for 中的最后一行,不一定要套在 if 中
|
class |
Call
Call 调用模板函数,两种用法:
1:常规调用
#@funcName(p1, p2, ..., pn)
2:安全调用,函数被定义才调用,否则跳过
#@funcName?(p1, p2, ..., pn)
注意:在函数名前面引入 '@' 字符是为了区分模板函数和指令
|
class |
Continue
Continue
|
class |
Define
Define 定义模板函数:
#define funcName(p1, p2, ..., pn)
body
#end
模板函数类型:
1:全局共享的模板函数
通过 engine.addSharedFunction(...) 添加,所有模板中可调用
2:模板中定义的局部模板函数
在模板中定义的模板函数,只在本模板中有效
高级用法:
1:局部模板函数可以与全局共享模板函数同名,调用时优先调用模板内模板数
2:模板内部不能定义同名的局部模板函数
|
class |
Else
Else
|
class |
ElseIf
ElseIf
|
class |
For
For 循环控制,支持 List、Map、数组、Collection、Iterator、Iterable
Enumeration、null 以及任意单个对象的迭代,简单说是支持所有对象迭代
主要用法:
1:#for(item : list) #(item) #end
2:#for(item : list) #(item) #else content #end
3:#for(i=0; i<9; i++) #(item) #end
4:#for(i=0; i<9; i++) #(item) #else content #end
|
class |
If
If
|
class |
Include
Include
1:父模板被缓存时,被 include 的模板会被间接缓存,无需关心缓存问题
2:同一个模板文件被多个父模板 include,所处的背景环境不同,例如各父模板中定义的模板函数不同
各父模板所处的相对路径不同,所以多个父模板不能共用一次 parse 出来的结果,而是在每个被include
的地方重新 parse
|
class |
NullStat
NullStat
|
class |
Output
Output 输出指令
用法:
1:#(value)
2:#(x = 1, y = 2, x + y)
3:#(seoTitle ?? 'JFinal 极速开发社区')
|
class |
Return
Return
通常用于 #define 指令内部,不支持返回值
|
class |
Set
Set 赋值,从内向外作用域查找变量,找到则替换变量值,否则在顶层作用域赋值
用法:
1:#set(k = v)
2:#set(k1 = v1, k2 = v2, ..., kn = vn)
3:#set(x = 1+2)
4:#set(x = 1+2, y = 3>4, ..., z = c ? a : b)
|
class |
SetGlobal
SetLocal 设置全局变量,全局作用域是指本次请求的整个 template
适用于极少数的在内层作用域中希望直接操作顶层作用域的场景
|
class |
SetLocal
SetLocal 设置局部变量
通常用于 #define #include 指令内部需要与外层作用域区分,以便于定义重用型模块的场景
也常用于 #for 循环内部的临时变量
|
class |
StatList
StatList
|
class |
Text
Text 输出纯文本块以及使用 "#[[" 与 "]]#" 定义的原样输出块
|
Modifier and Type | Field and Description |
---|---|
static Stat |
StatList.NULL_STAT |
static Stat[] |
StatList.NULL_STAT_ARRAY |
Modifier and Type | Method and Description |
---|---|
Stat |
StatList.getActualStat()
持有 StatList 的指令可以通过此方法提升 AST 执行性能
1:当 statArray.length > 1 时返回 StatList 自身
2:当 statArray.length == 1 时返回 statArray[0]
3:其它情况返回 NullStat
意义在于,当满足前面两个条件时,避免掉了 StatList.exec(...) 方法中的判断与循环
|
Stat |
StatList.getStat(int index) |
Stat |
Stat.setLocation(Location location) |
Modifier and Type | Method and Description |
---|---|
void |
ElseIf.setStat(Stat elseIfOrElse)
take over setStat(...) method of super class
|
void |
If.setStat(Stat elseIfOrElse)
take over setStat(...) method of super class
|
void |
Stat.setStat(Stat stat) |
Constructor and Description |
---|
For(ForCtrl forCtrl,
StatList statList,
Stat _else) |
Constructor and Description |
---|
StatList(List<Stat> statList) |
Copyright © 2018. All rights reserved.