From 794cb3a215543f2935a652050377f9acf84a9a8f Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 11 Dec 2023 19:11:07 +0800 Subject: [PATCH] [add] sui build process to include s:slots attribute for slot HTML --- sui/core/build.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sui/core/build.go b/sui/core/build.go index 78613de034..0971b9d7b2 100644 --- a/sui/core/build.go +++ b/sui/core/build.go @@ -7,6 +7,7 @@ import ( "strings" "github.com/PuerkitoBio/goquery" + jsoniter "github.com/json-iterator/go" "github.com/yaoapp/kun/log" ) @@ -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))