From 2b9bed85bac6906bd6c53bbe82057cc78d1af9f7 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Fri, 08 Jul 2022 17:39:17 +0800 Subject: [PATCH] 修改栏目发布bug --- src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java | 12 ++++++++---- 1 files changed, 8 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 c85e75e..f97655c 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 @@ -145,6 +145,7 @@ } } + runDataInject(); } @@ -158,15 +159,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,9 +177,10 @@ 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)) { + this.element.html(result); } else { this.element.attr(key, result); } -- Gitblit v1.9.1