feat: sui-page,add raw command
This commit is contained in:
parent
140d963883
commit
006859ba83
1 changed files with 14 additions and 0 deletions
|
|
@ -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},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue