From 1f3fdcdfa7508c3b0e5fc00b93eb7dc3c198cd03 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Fri, 08 Jul 2022 15:57:01 +0800 Subject: [PATCH] 添加模板解析日志 --- src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java | 36 ++++++++++++++++++++++++++++-------- 1 files changed, 28 insertions(+), 8 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 38c8fcc..16f3cd9 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 @@ -7,6 +7,7 @@ import com.xcong.farmer.cms.core.handler.DataParserHandler; import com.xcong.farmer.cms.core.tag.TagsEnum; import com.xcong.farmer.cms.core.template.Configuration; +import com.xcong.farmer.cms.core.template.TemplateConfiguration; import groovy.lang.Binding; import groovy.lang.GroovyShell; import org.apache.commons.text.StringSubstitutor; @@ -71,14 +72,7 @@ return false; } - public void parser() { - // 判断是否为最小节点,如果是且没有特殊标签,则跳过清空 - if (!isNeedEmpty()) { - return; - } - - this.element.empty(); - + public void staticPath() { // 设置img的链接访问 if ("img".equals(this.element.tagName())) { String src = this.element.attr("src"); @@ -86,6 +80,30 @@ this.element.attr("src", STATIC_URL + src); } } + + if ("link".equals(this.element.tagName())) { + String src = this.element.attr("href"); + if (StrUtil.isNotBlank(STATIC_URL)) { + this.element.attr("href", STATIC_URL + src); + } + } + + if ("script".equals(this.element.tagName())) { + String src = this.element.attr("src"); + if (StrUtil.isNotBlank(STATIC_URL)) { + this.element.attr("src", STATIC_URL + src); + } + } + } + + public void parser() { + staticPath(); + // 判断是否为最小节点,如果是且没有特殊标签,则跳过清空 + if (!isNeedEmpty()) { + return; + } + + this.element.empty(); Attributes attributes = this.element.attributes(); if (attributes.isEmpty()) { return; @@ -159,6 +177,8 @@ 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