summaryrefslogtreecommitdiffstats
path: root/cmd/web/templates.go
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-02-15 16:06:53 +0000
committerMatthew Lemon <y@yulqen.org>2024-02-15 16:10:20 +0000
commitf77f7f45e6e51edafcebf37b1253fa5db8e775ef (patch)
treeac526fb1dd43a96db4b7a501d65c6eb3e1edcf55 /cmd/web/templates.go
parentdd24746bcde550cffaf698a0c9c727e869e3cfb3 (diff)
Implementing the templateCache in organisations list
The render() function at the moment requires a templateData struct to be passed to it, but prior to this commit, that struct only had an Operations field in it. We have now added an Organisations field too - the thinking being that we only add the data we need for the page in question and the other fields remain as nil values. As of this commit - the slice of Organisations passed is not rendered correctly by the template - just a raw data dump to prove it works.
Diffstat (limited to '')
-rw-r--r--cmd/web/templates.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/cmd/web/templates.go b/cmd/web/templates.go
index 2457053..8cfa424 100644
--- a/cmd/web/templates.go
+++ b/cmd/web/templates.go
@@ -7,8 +7,11 @@ import (
"github.com/yulqen/ded-go-core/internal/models"
)
+// TODO: At the moment we are using a struct will have fields for all the data
+// we will need. Not sure whether this is good or bad at the moment.
type templateData struct {
- Operations []models.Operation
+ Operations []models.Operation
+ Organisations []models.Organisation
}
func newTemplateCache() (map[string]*template.Template, error) {