Skip to content

Commit

Permalink
Merge pull request #519 from trheyi/main
Browse files Browse the repository at this point in the history
[add] sui build process to include s:slots attribute for slot HTML
  • Loading branch information
trheyi authored Dec 11, 2023
2 parents 583f49f + 794cb3a commit 5cbd045
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions sui/core/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"

"github.com/PuerkitoBio/goquery"
jsoniter "github.com/json-iterator/go"
"github.com/yaoapp/kun/log"
)

Expand Down Expand Up @@ -174,6 +175,15 @@ func (page *Page) parse(doc *goquery.Document, option *BuildOption, warnings []s

if option.KeepPageTag {
sel.SetHtml(fmt.Sprintf("\n%s\n%s\n%s\n", style, addTabToEachLine(html), script))

// Set Slot HTML
slotsAttr, err := jsoniter.MarshalToString(slots)
if err != nil {
warns = append(warns, err.Error())
continue
}

sel.SetAttr("s:slots", slotsAttr)
continue
}
sel.ReplaceWithHtml(fmt.Sprintf("\n%s\n%s\n%s\n", style, html, script))
Expand Down

0 comments on commit 5cbd045

Please sign in to comment.