From 9bdf44d1fba033ac6a98ffec32ee29ff6fb22cf6 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Fri, 08 Jul 2022 17:00:14 +0800
Subject: [PATCH] fix
---
src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java b/src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java
index 16f3cd9..7d9cd18 100644
--- a/src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java
+++ b/src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java
@@ -158,15 +158,17 @@
String key = attribute.getKey().replaceAll("\\$", "");
String value = attribute.getValue();
+ String result = attrValueFormat(value);
// @{} 为java表达式; ${}为需要注入的数据项
if (value.startsWith("@{")) {
- value = value.replaceAll("\\@\\{", "").replaceAll("}", "");
+ value = result.replaceAll("\\@\\{", "").replaceAll("}", "");
Binding binding = new Binding();
for (Map.Entry<String, Object> entry : this.parserData.entrySet()) {
String fieldKey = entry.getKey();
Map<String, Object> data = (Map<String, Object>) entry.getValue();
- binding.setProperty(fieldKey, data);
- binding.setVariable(fieldKey + ".index", 1);
+ binding.setProperty(fieldKey, data.get("state"));
+ int index = (int) data.get("index");
+ binding.setVariable( "index", index);
}
GroovyShell shell = new GroovyShell(binding);
String evaluate = (String) shell.evaluate(value);
@@ -174,7 +176,6 @@
this.element.removeAttr("class");
this.element.attr("class", evaluate);
} else if (value.contains( "${")) {
- String result = attrValueFormat(value);
if ("text".equals(key)) {
this.element.text(result);
} else if ("html".equals(key)) {
--
Gitblit v1.9.1