goview icon indicating copy to clipboard operation
goview copied to clipboard

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

Open floor12 opened this issue 1 year ago • 2 comments

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.

floor12 avatar Oct 28 '23 08:10 floor12

You can config other extension:

 Extension: ".tpl", //file extension

foolin avatar Oct 28 '23 10:10 foolin

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{})

floor12 avatar Oct 28 '23 12:10 floor12