3 ms·
Then you didnt look very hard http://play.golang.org/p/DHk9iKnOMO http://play.golang.org/p/DHk9iKnOMO
by pram 11y ago
Then you didnt look very hard
http://play.golang.org/p/DHk9iKnOMO http://play.golang.org/p/DHk9iKnOMO
- reitanqild 11y ago?
- grey-area 11y agoYou can use the template function to include another named template.
- reitanqild 11y agoI don't know if I understand it correctly but I'm specifically looking to avoid every template looking like this: (old school php like) <?php include (header.php)?> ... business logic goes here... <?php include (footer.php)?>
- grey-area 11y agoI agree it is much nicer to have a layout template which includes your view templates (ala rails and many other systems), rather than including header/footer in each template. Yes you can do this, I handle this by having a layout template which includes a key for content, and rendering each view into its own template (without header/footer) which then goes into the content key of the layout. This is pretty straightforward to do though apparently not a usage they anticipated. They've recently introduced the concept of blocks too which is an attempt to solve this though it looked pretty clunky to me last time I looked. See this discussion from author of hugo asking how to use it (always a bad sign!): https://github.com/golang/go/issues/14285 https://github.com/golang/go/issues/14285 I think I prefer just rendering the view separately and then rendering it into the layout, it's easy to do.