Skip to content

Commit

Permalink
refactor: Add conditional hiding of elements in forStatementNode
Browse files Browse the repository at this point in the history
  • Loading branch information
trheyi committed Jul 6, 2024
1 parent 3f95dd7 commit a2d1ee8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions sui/core/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,24 @@ func (parser *TemplateParser) forStatementNode(sel *goquery.Selection) {
parser.data[indexVarName] = idx

// parser attributes
// Copy the if Attr from the parent node
if ifAttr, exists := new.Attr("s:if"); exists {

res, err := parser.data.Exec(ifAttr)
if err != nil {
parser.errors = append(parser.errors, fmt.Errorf("if statement %v error: %v", parser.sequence, err))
setError(new, err)
parser.show(new)
itemNodes = append(itemNodes, new.Nodes...)
continue
}

if res == true {
parser.hide(new)
continue
}
}

parser.parseElementAttrs(new)
parser.parsed(new)

Expand Down

0 comments on commit a2d1ee8

Please sign in to comment.