enjoy 4.6 release ^_^
This commit is contained in:
parent
8cf09eac35
commit
4069806028
@ -8,7 +8,7 @@ Enjoy 是基于 Java 语言的极轻量极魔板引擎。极轻量级仅 227 KB
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jfinal</groupId>
|
<groupId>com.jfinal</groupId>
|
||||||
<artifactId>enjoy</artifactId>
|
<artifactId>enjoy</artifactId>
|
||||||
<version>4.5</version>
|
<version>4.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<groupId>com.jfinal</groupId>
|
<groupId>com.jfinal</groupId>
|
||||||
<artifactId>enjoy</artifactId>
|
<artifactId>enjoy</artifactId>
|
||||||
<version>4.5</version>
|
<version>4.6</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,6 +102,14 @@ public class Template {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支持无 data 参数,渲染到 String 中去 <br>
|
||||||
|
* 适用于数据在模板中通过表达式和语句直接计算得出等等应用场景
|
||||||
|
*/
|
||||||
|
public String renderToString() {
|
||||||
|
return renderToString(null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 渲染到 StringBuilder 中去
|
* 渲染到 StringBuilder 中去
|
||||||
*/
|
*/
|
||||||
|
@ -49,7 +49,9 @@ public class MethodKit {
|
|||||||
System.class, Runtime.class, Thread.class, Class.class, ClassLoader.class, File.class,
|
System.class, Runtime.class, Thread.class, Class.class, ClassLoader.class, File.class,
|
||||||
Compiler.class, InheritableThreadLocal.class, Package.class, Process.class,
|
Compiler.class, InheritableThreadLocal.class, Package.class, Process.class,
|
||||||
RuntimePermission.class, SecurityManager.class, ThreadGroup.class, ThreadLocal.class,
|
RuntimePermission.class, SecurityManager.class, ThreadGroup.class, ThreadLocal.class,
|
||||||
java.lang.reflect.Method.class
|
|
||||||
|
java.lang.reflect.Method.class,
|
||||||
|
java.lang.reflect.Proxy.class
|
||||||
};
|
};
|
||||||
for (Class<?> c : cs) {
|
for (Class<?> c : cs) {
|
||||||
forbiddenClasses.add(c);
|
forbiddenClasses.add(c);
|
||||||
@ -62,8 +64,8 @@ public class MethodKit {
|
|||||||
"getClass", "getDeclaringClass", "forName", "newInstance", "getClassLoader",
|
"getClass", "getDeclaringClass", "forName", "newInstance", "getClassLoader",
|
||||||
"invoke", // "getMethod", "getMethods", // "getField", "getFields",
|
"invoke", // "getMethod", "getMethods", // "getField", "getFields",
|
||||||
"notify", "notifyAll", "wait",
|
"notify", "notifyAll", "wait",
|
||||||
"load", "exit", "loadLibrary", "halt",
|
"exit", "loadLibrary", "halt", // "load",
|
||||||
"stop", "suspend", "resume", "setDaemon", "setPriority",
|
"stop", "suspend", "resume" // "setDaemon", "setPriority"
|
||||||
};
|
};
|
||||||
for (String m : ms) {
|
for (String m : ms) {
|
||||||
forbiddenMethods.add(m);
|
forbiddenMethods.add(m);
|
||||||
|
@ -53,10 +53,9 @@ public class NumberDirective extends Directive {
|
|||||||
|
|
||||||
private Expr valueExpr;
|
private Expr valueExpr;
|
||||||
private Expr patternExpr;
|
private Expr patternExpr;
|
||||||
private int paraNum;
|
|
||||||
|
|
||||||
public void setExprList(ExprList exprList) {
|
public void setExprList(ExprList exprList) {
|
||||||
this.paraNum = exprList.length();
|
int paraNum = exprList.length();
|
||||||
if (paraNum == 0) {
|
if (paraNum == 0) {
|
||||||
throw new ParseException("The parameter of #number directive can not be blank", location);
|
throw new ParseException("The parameter of #number directive can not be blank", location);
|
||||||
}
|
}
|
||||||
@ -64,13 +63,8 @@ public class NumberDirective extends Directive {
|
|||||||
throw new ParseException("Wrong number parameter of #number directive, two parameters allowed at most", location);
|
throw new ParseException("Wrong number parameter of #number directive, two parameters allowed at most", location);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paraNum == 1) {
|
valueExpr = exprList.getExpr(0);
|
||||||
this.valueExpr = exprList.getExpr(0);
|
patternExpr = (paraNum == 1 ? null : exprList.getExpr(1));
|
||||||
this.patternExpr = null;
|
|
||||||
} else if (paraNum == 2) {
|
|
||||||
this.valueExpr = exprList.getExpr(0);
|
|
||||||
this.patternExpr = exprList.getExpr(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void exec(Env env, Scope scope, Writer writer) {
|
public void exec(Env env, Scope scope, Writer writer) {
|
||||||
@ -79,9 +73,9 @@ public class NumberDirective extends Directive {
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paraNum == 1) {
|
if (patternExpr == null) {
|
||||||
outputWithoutPattern(writer, value);
|
outputWithoutPattern(writer, value);
|
||||||
} else if (paraNum == 2) {
|
} else {
|
||||||
outputWithPattern(scope, writer, value);
|
outputWithPattern(scope, writer, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user