From 006859ba833ad4ddc3914d34964b9bc399c212d0 Mon Sep 17 00:00:00 2001 From: wwsheng009 Date: Mon, 18 Dec 2023 13:35:12 +0800 Subject: [PATCH] feat: sui-page,add raw command --- sui/core/parser.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sui/core/parser.go b/sui/core/parser.go index 28a34971..b3814e3e 100644 --- a/sui/core/parser.go +++ b/sui/core/parser.go @@ -176,6 +176,17 @@ func (parser *TemplateParser) parseElementAttrs(sel *goquery.Selection) { } } +// check if element attributes has the s:raw command, if true,ouput the raw data. +func checkIsRawElement(node *html.Node) bool { + if node.Parent != nil && len(node.Parent.Attr) > 0 { + for _, attr := range node.Parent.Attr { + if attr.Key == "s:raw" && attr.Val == "true" { + return true + } + } + } + return false +} func (parser *TemplateParser) parseTextNode(node *html.Node) { parser.sequence = parser.sequence + 1 res, hasStmt := parser.data.Replace(node.Data) @@ -184,6 +195,9 @@ func (parser *TemplateParser) parseTextNode(node *html.Node) { bindings := strings.TrimSpace(node.Data) key := fmt.Sprintf("%v", parser.sequence) if bindings != "" { + if checkIsRawElement(node) { + node.Type = html.RawNode + } node.Parent.Attr = append(node.Parent.Attr, []html.Attribute{ {Key: "s:bind", Val: bindings}, {Key: "s:key-text", Val: key},