From d5706f0826f28b571c94edb8faca4bdd7d9c7bb3 Mon Sep 17 00:00:00 2001 From: iacore Date: Fri, 23 Aug 2024 15:52:59 +0000 Subject: [PATCH] add comments --- routes/render_.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/routes/render_.go b/routes/render_.go index bd88876..bc57c0f 100644 --- a/routes/render_.go +++ b/routes/render_.go @@ -113,13 +113,12 @@ type Data_user struct { Page string MetaImage string } -// add new types above -// the migration plan -// -// 1. find and replace every occurance of `c.Render("abc" struct {...})` with `Render(c, Data_abc{...})` (except in this file) -// 2. create type `Data_abc` in this file (see `Data_error` above) -// 3. update `TestTemplates` in render_test.go to include `Data_abc` +// add new types above this line +// whenever you add new types, update `TestTemplates` in render_test.go to include the type in the test + +// caution: do not use pointer in Data_* struct. faker will insert nil. +// caution: do not name template file a.b.jet.html or it won't be able to be used here. Data_a.b is not a valid identifier. func Render[T interface{}](c *fiber.Ctx, data T) error { template_name, found := strings.CutPrefix(reflect.TypeFor[T]().Name(), "Data_")