goaltools / goal

Goal is a toolkit for high productivity web development in Go language in the spirit of Revel Framework that is built around the concept of code generation.
BSD 2-Clause "Simplified" License
87 stars 3 forks source link

Revel Framework like Render method #1

Closed ghost closed 9 years ago

ghost commented 9 years ago

Initial version of Goal had a tool that scanned user's views directory and produced a package like this. It was assumed user would import that package and use it as follows:

func (c App) MyAction() http.Handler {
    return c.RenderTemplate(generatedPackageName.Paths.To.Some.FileHTML)
}

So, this is similar to Revel Framework's c.RenderTemplate("path/to/some/file.html") but type safe: if you use a wrong (non-existent) path your app will not be compiled. So, you know early the template is missing instead of getting a runtime surprise in a form of Internal Error 500 when you're trying to visit some page of your app.

However, now I think it would be better to use something like Revel's c.Render() but reflectionless. It would be more difficult to make sure user renders the template that does exist. But that's possible. And as a result user would need to type just c.Render() instead of c.RenderTemplate(views.Paths.ControllerName.ActionNameHTML). We need a tool that will scan user's controllers and find all calls of c.Render and make sure their arguments are correct.

P.S.: I have already removed the old tool that was responsible for generation of the above mentioned packages. So, Goal is mostly unusable now. That's why this should be resolved ASAP.

ghost commented 9 years ago

I'm closing this for now as Render method has been added. Though a tool that would check existence of templates is still needed.