gin-gonic / contrib

Collection of middlewares created by the community

Home Page:https://gin-gonic.github.io/gin/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

enhancing multi template and rendering

madhums opened this issue · comments

Hi, first of all thanks for the awesome library. One of the things most people struggle when starting with gin (directly hopping from communities like rails, express, django) is templates and rendering.

From usability p.o.v, one of the things that struck me while using gin/multitemplate was, the following needs to be changed every time you add a new template or delete one of them. Which is not too handy and becomes repetitive to do in each handler when you are building a large application.

r.AddFromFiles("article", "base.html", "article.html")
r.AddFromFiles("login", "base.html", "login.html")
// ...

So based on multi template and the article I put some effort in enhancing the abilities. I would like to ask your opinion on it and decide if it can be used in multi template or make another package multitemplate-extras or drop it.

Here's the gist https://gist.github.com/madhums/4340cbeb36871e227905 (It contains a readme and a .go file. It also contains link to a full demo, new comers may find it useful)

@manucorporat your feedback is highly appreciated. Thanks!

@madhums are you still working on this? I find it helpful and I wanted to add includes directory for re-usable layout components.