foolin / goview

Goview is a lightweight, minimalist and idiomatic template library based on golang html/template for building Go web application.
MIT License
425 stars 36 forks source link

Switching between rendering with the parent layout or not by adding .HTML to template name #36

Open floor12 opened 1 year ago

floor12 commented 1 year ago

First of all, thank you for the work you've done; you have a great project.

The only thing that concerns me in your project is the use of .html in the template name. It affects whether the parent layout will be applied or not. In my opinion, this is a terrible decision that goes against the Go language ideology, where simplicity and clarity of the code are paramount. In this case, there is no clear way for a new project contributor to understand how the template name determines whether it will be rendered with the parent layout or not without documentation. I believe that, without breaking backward compatibility, it's possible to keep the option of using .html and add another, more explicit way to specify whether a template will be rendered with a parent layout or not. Than you.

foolin commented 1 year ago

You can config other extension:

  Extension: ".tpl", //file extension
floor12 commented 1 year ago

I'm talking about something else. It would be clearer to say instead of this, where without reading the documentation, the difference is not understood:

goview.Render(w, http.StatusOK, "index", goview.M{})
goview.Render(w, http.StatusOK, "index.html", goview.M{}) 

Use something like this:

goview.Render(w, http.StatusOK, "index", goview.M{})
goview.RenderPartial(w, http.StatusOK, "index", goview.M{})