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. Converts templates into Go code and then compiles it. -
amber
Amber is an elegant templating engine for Go Programming Language It is inspired from HAML and Jade. -
ace
Ace is an HTML template engine for Go, inspired by Slim and Jade. Ace is a refinement of Gold. -
Plush
Plush is the templating system that Go both needs and deserves. Powerful, flexible, and extendable, Plush is there to make writing your templates that much easier. -
fasttemplate
Simple and fast template engine. Substitutes template placeholders up to 10x faster than text/template. -
ego
A lightweight templating language that lets you write templates in Go. Templates are translated into Go and compiled. -
maroto
A maroto way to create PDFs. Maroto is inspired in Bootstrap and uses gofpdf. Fast and simple. -
Soy
Closure templates (aka Soy templates) for Go, following the official spec -
goview
Goview is a lightweight, minimalist and idiomatic template library based on golang html/template for building Go web application. -
extemplate
Tiny wrapper around html/template to allow for easy file-based template inheritance. -
gospin
Article spinning and spintax/spinning syntax engine, useful for A/B, testing pieces of text/articles and creating more natural conversations. -
damsel
Markup language featuring html outlining via css-selectors, extensible via pkg html/template and others.
Scout APM - Leading-edge performance monitoring starting at $39/month
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.