enjoy 3.5

This commit is contained in:
James
2018-08-12 12:15:01 +08:00
parent 3e89651aa4
commit 1ce7068072
16 changed files with 183 additions and 95 deletions

View File

@@ -79,23 +79,25 @@ public class DateDirective extends Directive {
private void outputWithoutDatePattern(Env env, Scope scope, Writer writer) {
Object value = valueExpr.eval(scope);
if (value != null) {
if (value instanceof Date) {
write(writer, (Date)value, env.getEngineConfig().getDatePattern());
} else if (value != null) {
throw new TemplateException("The first parameter date of #date directive must be Date type", location);
}
}
private void outputWithDatePattern(Env env, Scope scope, Writer writer) {
Object value = valueExpr.eval(scope);
if (value == null) {
return ;
if (value instanceof Date) {
Object datePattern = this.datePatternExpr.eval(scope);
if (datePattern instanceof String) {
write(writer, (Date)value, (String)datePattern);
} else {
throw new TemplateException("The sencond parameter datePattern of #date directive must be String", location);
}
} else if (value != null) {
throw new TemplateException("The first parameter date of #date directive must be Date type", location);
}
Object datePattern = this.datePatternExpr.eval(scope);
if ( !(datePattern instanceof String) ) {
throw new TemplateException("The sencond parameter datePattern of #date directive must be String", location);
}
write(writer, (Date)value, (String)datePattern);
}
private void write(Writer writer, Date date, String datePattern) {

View File

@@ -52,11 +52,12 @@ public class EscapeDirective extends Directive {
case '>':
ret.append(">");
break;
case '\"':
case '"':
ret.append(""");
break;
case '\'':
ret.append("'"); // IE 不支持 ' 考虑 '
// ret.append("'"); // IE 不支持 ' 考虑 '
ret.append("'");
break;
case '&':
ret.append("&");

View File

@@ -16,8 +16,8 @@
package com.jfinal.template.ext.directive;
import java.util.HashMap;
import java.util.Map;
import com.jfinal.kit.SyncWriteMap;
import com.jfinal.template.Directive;
import com.jfinal.template.EngineConfig;
import com.jfinal.template.Env;
@@ -60,7 +60,7 @@ import com.jfinal.template.stat.ast.StatList;
public class RenderDirective extends Directive {
private String parentFileName;
private Map<String, StatInfo> statInfoCache = new HashMap<String,StatInfo>();
private Map<String, StatInfo> statInfoCache = new SyncWriteMap<String,StatInfo>(16, 0.5F);
public void setExprList(ExprList exprList) {
int len = exprList.length();