extemplate alternatives and similar packages
Based on the "Template Engines" category.
Alternatively, view extemplate alternatives based on common mentions on social networks and blogs.
-
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. -
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 -
Blip Template Engine for Go
Go Template Engine for type safe / fast rendering Benefits: Very Fast rendering Compile time type checking, Type safe! Template Extending / Including Simple syntax Auto-Escaping Support passing variables directly and via context Extendable escaping / monitoring
CodeRabbit: AI Code Reviews for Developers
Do you think we are missing an alternative of extemplate or a related project?
Popular Comparisons
README
Extemplate
Extemplate is a small wrapper package around html/template to allow for easy file-based template inheritance.
File: templates/parent.tmpl
<html>
<head>
<title>{{ block "title" }}Default title{{ end }}</title>
</head>
<body>
{{ block "content" }}Default content{{ end }}
</body>
</html>
File: templates/child.tmpl
{{ extends "parent.tmpl" }}
{{ define "title" }}Child title{{ end }}
{{ define "content" }}Hello world!{{ end }}
File: main.go
xt := extemplate.New()
xt.ParseDir("templates/", []string{".tmpl"})
_ = xt.ExecuteTemplate(os.Stdout, "child.tmpl", "no data needed")
// Output: <html>.... Hello world! ....</html>
Extemplate recursively walks all files in the given directory and will parse the files matching the given extensions as a template. Templates are named by path and filename, relative to the root directory.
For example, calling ParseDir("templates/", []string{".tmpl"})
on the following directory structure:
templates/
|__ admin/
| |__ index.tmpl
| |__ edit.tmpl
|__ index.tmpl
Will result in the following templates:
admin/index.tmpl
admin/edit.tmpl
index.tmpl
Check out the tests and examples directory for more examples.
Benchmarks
You will most likely never have to worry about performance, when using this package properly. The benchmarks are purely listed here so we have a place to keep track of progress.
BenchmarkExtemplateGetLayoutForTemplate-8 2000000 923 ns/op 104 B/op 3 allocs/op
BenchmarkExtemplateParseDir-8 5000 227898 ns/op 34864 B/op 325 allocs/op
License
MIT
*Note that all licence references and agreements mentioned in the extemplate README section above
are relevant to that project's source code only.