fix
Helius
2022-07-08 9bdf44d1fba033ac6a98ffec32ee29ff6fb22cf6
fix
1 files modified
9 ■■■■■ changed files
src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java 9 ●●●●● patch | view | raw | blame | history
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)) {