|
@@ -3,12 +3,13 @@ package partial
|
|
|
import (
|
|
|
"fmt"
|
|
|
"os"
|
|
|
+ "path"
|
|
|
"strings"
|
|
|
|
|
|
"git.clearsky.net.au/cody/gex.git/gen/domquery"
|
|
|
)
|
|
|
|
|
|
-func ProcessHTML(htmlStr string) (string, error) {
|
|
|
+func ProcessHTML(htmlStr string, fp string) (string, error) {
|
|
|
dom := domquery.LoadHTML(htmlStr)
|
|
|
|
|
|
partTag := dom.QuerySelector("part")
|
|
@@ -18,7 +19,13 @@ func ProcessHTML(htmlStr string) (string, error) {
|
|
|
}
|
|
|
|
|
|
attr := partTag.GetAttribute("src")
|
|
|
+
|
|
|
+ // Set path
|
|
|
attr = strings.TrimPrefix(attr, "/")
|
|
|
+ if !strings.Contains(attr, "app/") {
|
|
|
+ dirPath := path.Dir(fp)
|
|
|
+ attr = dirPath + "/" + attr
|
|
|
+ }
|
|
|
attr = strings.Replace(attr, ".tpl", ".gen.tpl", 1)
|
|
|
|
|
|
partFileByt, err := os.ReadFile(attr)
|
|
@@ -35,7 +42,7 @@ func ProcessHTML(htmlStr string) (string, error) {
|
|
|
}
|
|
|
partTag.SetOuterHTML(partFileDom.InnerHTML())
|
|
|
|
|
|
- htmlStr, err = ProcessHTML(dom.InnerHTML())
|
|
|
+ htmlStr, err = ProcessHTML(dom.InnerHTML(), fp)
|
|
|
if err != nil {
|
|
|
fmt.Printf("ERROR: %s", err)
|
|
|
return "", err
|