New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to turn off caching in development mode? #61
Comments
I assume your code looks something like this:
As you can see, the call to LoadHTMLTemplates is invoked only when the program starts. Hence the templates is only loaded once. One solution is to put the call to LoadHTMLTemplates inside the route function. This will reload the templates on every request.
However, this may not be what you want in production. There is, unfortunately with the same name, a library[0] that enables live reload. I have not experimented with it yet so I cannot say if it works. |
Yeah! Whether can draw lessons from this example: r := render.New(render.Options{
Delims: render.Delims{"[[", "]]"},
IsDevelopment: true,
}) |
The new flexible render system allows us to easily change the default HTML render. |
Really?How to use ? |
Now: c.JSON(200, data) is the same as: c.Render(200, render.JSON, data)
type Render interface {
Render(http.ResponseWriter, int, ...interface{}) error
} so you can create your own struct that implements Render() and you can use it in c.Render(). This new feature also allows us to change the default HTML render or even the default JSON/XML render! we could easily use solutions such as:
You can change the default HTML render using this code: r := gin.Default()
r.HTMLRender = your_awesome_render |
Thanks a lot! |
I started some work around a development mode for GIN. #96 |
I think I fixed this issue in this commit: 46225ea Check out the |
It doesn't work at |
gin has special method for development mode. See this example: // enable debug mode. Is this mode is set - gin will use HTMLDebugRenderer
// which load template on each call
gin.SetMode(gin.DebugMode)
router := gin.Default()
router.LoadHTMLGlob("templates/*")
router.GET("/index", s.handleIndex) |
Now ,when I update the ".tmpl" files, I can't see the latest changes
The text was updated successfully, but these errors were encountered: