Migrate viewutil
This commit is contained in:
parent
72b079cc2e
commit
132882c37c
@ -3,11 +3,12 @@ package newtmpl
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"strings"
|
||||
|
||||
"github.com/bouncepaw/mycorrhiza/internal/cfg"
|
||||
"github.com/bouncepaw/mycorrhiza/util"
|
||||
"github.com/bouncepaw/mycorrhiza/web/viewutil"
|
||||
"html/template"
|
||||
"strings"
|
||||
)
|
||||
|
||||
//go:embed *.html
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
package viewutil
|
||||
|
||||
import (
|
||||
"github.com/bouncepaw/mycorrhiza/internal/user"
|
||||
"github.com/bouncepaw/mycorrhiza/l18n"
|
||||
"html/template"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/bouncepaw/mycorrhiza/internal/user"
|
||||
"github.com/bouncepaw/mycorrhiza/l18n"
|
||||
)
|
||||
|
||||
// Meta is a bundle of common stuffs used by views, templates.
|
||||
|
||||
@ -6,7 +6,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/bouncepaw/mycorrhiza/internal/cfg"
|
||||
"io/fs"
|
||||
"log"
|
||||
"log/slog"
|
||||
"strings"
|
||||
"text/template" // TODO: save the world
|
||||
|
||||
@ -125,7 +125,7 @@ func Base(meta Meta, title, body string, bodyAttributes map[string]string, headE
|
||||
BodyAttributes: bodyAttributes,
|
||||
})
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
slog.Info("Failed to execute the legacy Base template; proceeding anyway", "err", err)
|
||||
}
|
||||
return w.String()
|
||||
}
|
||||
@ -149,7 +149,7 @@ func ExecutePage(meta Meta, chain Chain, data interface {
|
||||
}) {
|
||||
data.withBaseValues(meta, HeaderLinks, cfg.CommonScripts)
|
||||
if err := chain.Get(meta).ExecuteTemplate(meta.W, "page", data); err != nil {
|
||||
log.Println(err)
|
||||
slog.Info("Failed to execute page; proceeding anyway", "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user