Skip to content

Commit

Permalink
add parseTree work
Browse files Browse the repository at this point in the history
  • Loading branch information
datewu committed Sep 12, 2023
1 parent 7086295 commit 941ae9f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions front/table.tpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"html/template"
"io"
"log"
"time"

apps "k8s.io/api/apps/v1"
Expand All @@ -15,7 +16,6 @@ import (
var tableHtml string

var tableTpl = template.Must(template.New("table").Parse(tableHtml))
var tableTplWithLayout = template.Must(template.New("table").Parse(tableHtml + layoutHtml))

// TableView ...
type TableView struct {
Expand Down Expand Up @@ -121,7 +121,17 @@ func (t TableView) Render(w io.Writer, user string) {
User: user,
TableView: t,
}
tableTplWithLayout.Execute(w, data)
// tableTplWithLayout.Execute(w, data)
t, err := tableTpl.Clone()
if err != nil {
log.Fatalln("clone failed:", err)
}
a, err := t.AddParseTree("l", layoutTpl.Tree.Copy())
if err != nil {
log.Fatalln("add parse tree failed:", err)
}
a.Execute(w, data)
// t.ExecuteTemplate(os.Stdout, "l",data)
return
}
tableTpl.ExecuteTemplate(w, "content", t)
Expand Down

0 comments on commit 941ae9f

Please sign in to comment.