package spitz

import "stathat.com/c/spitz"

Install: go get stathat.com/c/spitz

spitz is a package to help manage a pool of html templates. It uses html/template for all template parsing and execution. spitz supports simple layouts with a header and a footer. spitz can also be configured to reparse templates when they change on disk, making front-end development faster.

Usage

Create a new instance with a content directory and whether or not to reload templates when they change:

pool := spitz.New("/opt/content", true)

Then register templates:

err := pool.Register("docs/index", "", "")

The second two parameters are the left and right delimiters. Leaving them blank uses the default. This will register the template with the following path: /opt/content/docs/index.tmpl.html.

To render a single template, do:

err := pool.RenderNoLayout("docs/index", data, writer)

You can also register layouts:

err := pool.Register("admin", "layouts/admin_header", "layouts/admin_footer", "", "")

To render a template with an enclosing layout, do:

err := pool.Render("admin", "admin/dashboard", data, writer)

You can also render to string and register multiple template files at once. See the godoc for more.