enjoy 4.6 release ^_^

This commit is contained in:
James 2019-10-13 22:36:49 +08:00
parent 8cf09eac35
commit 4069806028
5 changed files with 20 additions and 16 deletions

View File

@ -8,7 +8,7 @@ Enjoy 是基于 Java 语言的极轻量极魔板引擎。极轻量级仅 227 KB
<dependency>
<groupId>com.jfinal</groupId>
<artifactId>enjoy</artifactId>
<version>4.5</version>
<version>4.6</version>
</dependency>
```

View File

@ -4,7 +4,7 @@
<groupId>com.jfinal</groupId>
<artifactId>enjoy</artifactId>
<version>4.5</version>
<version>4.6</version>
<packaging>jar</packaging>

View File

@ -102,6 +102,14 @@ public class Template {
}
}
/**
* 支持无 data 参数渲染到 String 中去 <br>
* 适用于数据在模板中通过表达式和语句直接计算得出等等应用场景
*/
public String renderToString() {
return renderToString(null);
}
/**
* 渲染到 StringBuilder 中去
*/

View File

@ -49,7 +49,9 @@ public class MethodKit {
System.class, Runtime.class, Thread.class, Class.class, ClassLoader.class, File.class,
Compiler.class, InheritableThreadLocal.class, Package.class, Process.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) {
forbiddenClasses.add(c);
@ -62,8 +64,8 @@ public class MethodKit {
"getClass", "getDeclaringClass", "forName", "newInstance", "getClassLoader",
"invoke", // "getMethod", "getMethods", // "getField", "getFields",
"notify", "notifyAll", "wait",
"load", "exit", "loadLibrary", "halt",
"stop", "suspend", "resume", "setDaemon", "setPriority",
"exit", "loadLibrary", "halt", // "load",
"stop", "suspend", "resume" // "setDaemon", "setPriority"
};
for (String m : ms) {
forbiddenMethods.add(m);

View File

@ -53,10 +53,9 @@ public class NumberDirective extends Directive {
private Expr valueExpr;
private Expr patternExpr;
private int paraNum;
public void setExprList(ExprList exprList) {
this.paraNum = exprList.length();
int paraNum = exprList.length();
if (paraNum == 0) {
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);
}
if (paraNum == 1) {
this.valueExpr = exprList.getExpr(0);
this.patternExpr = null;
} else if (paraNum == 2) {
this.valueExpr = exprList.getExpr(0);
this.patternExpr = exprList.getExpr(1);
}
valueExpr = exprList.getExpr(0);
patternExpr = (paraNum == 1 ? null : exprList.getExpr(1));
}
public void exec(Env env, Scope scope, Writer writer) {
@ -79,9 +73,9 @@ public class NumberDirective extends Directive {
return ;
}
if (paraNum == 1) {
if (patternExpr == null) {
outputWithoutPattern(writer, value);
} else if (paraNum == 2) {
} else {
outputWithPattern(scope, writer, value);
}
}