Layout/master HTML templates

I come from ASP.NET and miss master pages. The Render package includes some useful time savers including a Layouts feature. Could something similar to Layouts become part of the standard library or is there a reason I’m missing to avoid doing so?

Go’s html/template package should get support for blocks in 1.6 - as per the post below yours: Text/template blocks and redefinition

Right now you can use the unrolled/render package and its {{yield}} & {{block}} expressions to achieve a similar thing: https://github.com/unrolled/render

If there’s something else you want to do that Razor does, mock up an example and I should be able to show you the Go approach.

3 Likes

For templating and using blocks and such functions, I’ve used https://github.com/flosch/pongo2 for a project.

It works good - especially if you’re used to working with Twig or Jinja2 :slight_smile:

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.