Skip to content

Commit

Permalink
Merge pull request #660 from trheyi/main
Browse files Browse the repository at this point in the history
refactor: Add conditional hiding of elements in forStatementNode
  • Loading branch information
trheyi committed Jul 6, 2024
2 parents 5178e4a + a2d1ee8 commit 63528c0
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 63528c0

Please sign in to comment.