I can display the posts in a topic, albeit imperfectly

This commit is contained in:
2025-12-29 23:17:27 -07:00
parent 07395b9c1d
commit d87b4b9411
4 changed files with 38 additions and 17 deletions
+22
View File
@@ -62,6 +62,7 @@ type AmContext interface {
ReplaceUser(*database.User)
SaveSession() error
SubRender(string) ([]byte, error)
SubRender2(string, map[string]any) ([]byte, error)
SetCommunityContext(string) error
SetLeftMenu(string)
SetLoginCookie(string)
@@ -320,6 +321,27 @@ func (c *amContext) SubRender(name string) ([]byte, error) {
return buf.Bytes(), err
}
func (c *amContext) SubRender2(name string, vals map[string]any) ([]byte, error) {
view, err := views.GetTemplate(name)
if err != nil {
log.Errorf("unable to load template \"%s\": %v", name, err)
return nil, err
}
newmap := make(jet.VarMap)
for k, v := range c.VarMap() {
newmap.Set(k, v)
}
for k, v := range vals {
newmap.Set(k, v)
}
buf := new(bytes.Buffer)
err = view.Execute(buf, newmap, c)
if err != nil {
log.Errorf("template \"%s\" failed subrender exec: %v", name, err)
}
return buf.Bytes(), err
}
/* SetCommunityContext establishes the community context from a (ID or alias) parameter.
* Parameters:
* param - String parameter selecting the community.