Merge pull request #555 from trheyi/main

Update regular expressions in data.go
This commit is contained in:
Max 2024-01-17 19:18:59 +08:00 committed by GitHub
commit 47796a1886
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View file

@ -11,8 +11,9 @@ import (
"github.com/yaoapp/kun/log" "github.com/yaoapp/kun/log"
) )
var stmtRe = regexp.MustCompile(`\{\{([^}]+)\}\}`) // If set the map value, should keep the space at the end of the statement
var propRe = regexp.MustCompile(`\[\{([^}]+)\}\]`) var stmtRe = regexp.MustCompile(`\{\{([\s\S]*?)\}\}`)
var propRe = regexp.MustCompile(`\[\{([\s\S]*?)\}\]`)
// Data data for the template // Data data for the template
type Data map[string]interface{} type Data map[string]interface{}

View file

@ -331,6 +331,9 @@ func (parser *TemplateParser) ifStatementNode(sel *goquery.Selection) {
} }
if res == true { if res == true {
parser.removeParsed(sel)
parser.parseElementAttrs(sel)
parser.parsed(sel)
parser.show(sel) parser.show(sel)
return return
} }
@ -345,6 +348,9 @@ func (parser *TemplateParser) ifStatementNode(sel *goquery.Selection) {
} }
if res == true { if res == true {
parser.removeParsed(elifNode)
parser.parseElementAttrs(elifNode)
parser.parsed(elifNode)
parser.show(elifNode) parser.show(elifNode)
return return
} }
@ -352,6 +358,9 @@ func (parser *TemplateParser) ifStatementNode(sel *goquery.Selection) {
// else // else
if elseNode != nil { if elseNode != nil {
parser.removeParsed(elseNode)
parser.parseElementAttrs(elseNode)
parser.parsed(elseNode)
parser.show(elseNode) parser.show(elseNode)
} }
} }