grender alternatives and similar packages
Based on the "Template Engines" category.
Alternatively, view grender alternatives based on common mentions on social networks and blogs.
-
gofpdf
A PDF document generator with high level support for text, drawing and images. -
quicktemplate
Fast, powerful, yet easy to use template engine for Go. Optimized for speed, zero memory allocations in hot paths. Up to 20x faster than html/template -
maroto
A maroto way to create PDFs. Maroto is inspired in Bootstrap and uses gofpdf. Fast and simple. -
amber
Amber is an elegant templating engine for Go Programming Language, inspired from HAML and Jade -
goview
Goview is a lightweight, minimalist and idiomatic template library based on golang html/template for building Go web application. -
kasia.go
Templating system for HTML and other text documents - go implementation -
extemplate
Wrapper package for Go's template/html to allow for easy file-based template inheritance. -
gospin
Article spinning and spintax/spinning syntax engine written in Go, useful for A/B, testing pieces of text/articles and creating more natural conversations -
damsel
Package damsel provides html outlining via css-selectors and common template functionality. -
tbd
"to be defined" - a really simple way to create text templates with placeholders -
GoT
GoT is a template engine that turns templates into Go code to compile into your app.
Access the most powerful time series database as a service
Do you think we are missing an alternative of grender or a related project?
Popular Comparisons
README
Grender

Deprecation notice
This package could be more focused, so it was split up into two improved packages:
- dannyvankooten/respond for responding to HTTP requests.
- dannyvankooten/extemplate for file-based template inheritance using html/template.
Grender is a package that provides functionality for easily rendering HTML templates and JSON or XML data to a HTTP response. It is based on github.com/unrolled/render with some subtle modifications when it comes to rendering HTML templates.
- Templates inheritance:
{{/* extends "master.tmpl" */}}
- Glob configuration:
templates/*.tmpl
- Normal templates as partials:
{{ template "footer" .}}
Usage
Grender can be used with pretty much any web framework providing you can access the http.ResponseWriter
from your handler. The rendering functions simply wraps Go's existing functionality for marshaling and rendering data.
- HTML: Uses the html/template package to render HTML templates.
- JSON: Uses the encoding/json package to marshal data into a JSON-encoded response.
- XML: Uses the encoding/xml package to marshal data into an XML-encoded response.
- Text: Passes the incoming string straight through to the
http.ResponseWriter
.
// main.go
package main
import (
"net/http"
"github.com/dannyvankooten/grender"
)
func main() {
r := grender.New(grender.Options{
Charset: "ISO-8859-1",
TemplatesGlob: "examples/*.tmpl",
})
mux := http.NewServeMux()
// This will set the Content-Type header to "application/json; charset=ISO-8859-1".
mux.HandleFunc("/json", func(w http.ResponseWriter, req *http.Request) {
r.JSON(w, http.StatusOK, map[string]string{"hello": "world"})
})
// This will set the Content-Type header to "text/html; charset=ISO-8859-1".
mux.HandleFunc("/html", func(w http.ResponseWriter, req *http.Request) {
r.HTML(w, http.StatusOK, "hello.tmpl", "world")
})
http.ListenAndServe("127.0.0.1:3000", mux)
}
Options
Grender comes with a variety of configuration options. The defaults are listed below.
r := grender.New(grender.Options{
Debug: false, // If true, templates will be recompiled before each render call
TemplatesGlob: "", // Glob to your template files
PartialsGlob: "", // Glob to your patials or global templates
Funcs: nil, // Your template FuncMap
Charset: "UTF-8", // Charset to use for Content-Type header values
})
Extending another template
First, define your parent template like this.
file: master.tmpl
<html>
{{template "content" .}}
</html>
Then, in a separate template file use a template comment on the first line to indicate that you want to extend the other template file.
file: child.tmpl
{{/* extends "master.tmpl" */}}
{{define "content"}}Hello world!{{end}}
More examples
The [grender_test.go](grender_test.go) file contains additional usage examples.
License
See [LICENSE](LICENSE) file.
*Note that all licence references and agreements mentioned in the grender README section above
are relevant to that project's source code only.