6 Commits

Author SHA1 Message Date
James
0f27710991 enjoy 4.7 release ^_^ 2019-10-30 00:06:13 +08:00
James
c4ef9561bc enjoy 4.6 2019-10-30 00:05:01 +08:00
James
1996b12013 enjoy 4.7 release ^_^ 2019-10-30 00:01:20 +08:00
James
4069806028 enjoy 4.6 release ^_^ 2019-10-13 22:36:49 +08:00
James
8cf09eac35 enjoy 4.5 2019-09-01 22:27:20 +08:00
James
550ddaba53 enjoy 4.5 2019-09-01 22:02:46 +08:00
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.4</version>
<version>4.7</version>
</dependency>
```

View File

@@ -4,7 +4,7 @@
<groupId>com.jfinal</groupId>
<artifactId>enjoy</artifactId>
<version>4.4</version>
<version>4.7</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);
}
}