refactor: Create context if not exists in SUI page build

This commit is contained in:
Max 2024-07-02 20:51:57 +08:00
parent 28537e2163
commit 35e23f29ae

View file

@ -22,6 +22,11 @@ var langAttrRe = regexp.MustCompile(`'::(.*?)'`)
// Build is the struct for the public
func (page *Page) Build(ctx *BuildContext, option *BuildOption) (*goquery.Document, []string, error) {
// Create the context if not exists
if ctx == nil {
ctx = NewBuildContext(nil)
}
warnings := []string{}
html, err := page.BuildHTML(option)
if err != nil {
@ -34,9 +39,6 @@ func (page *Page) Build(ctx *BuildContext, option *BuildOption) (*goquery.Docume
warnings = append(warnings, err.Error())
}
// Add components scripts and styles
ctx.doc = doc
// Append the nested html
err = page.parse(ctx, doc, option, warnings)
if err != nil {