Template caching and paging utilities. Require go 1.22+
go get github.com/mawngo/go-tmpls
Cache the template for re-execution without having to parse it again, support template reload for development.
See examples for setup and integrating template cache.
By default, this library adds some helpers to the template.
To disable all built-in functions useWithoutBuiltins()
, or WithoutBuiltins('fn1', 'fn2', ...)
to disable specific
function.
You can add custom funcs using WithFuncs
.
By default, this library uses a map to store all parsed templates, thus make them never expire. If you want expiration,
use WithCache(impl)
to provide your own Cache[*template.Template]
implementation.
When cache is enabled (default), change to the template that has been parsed will not be visible until you rerun the project (or the cache expired if you use custom cache implementation).
Use WithNocache(true)
to disable template cache, force template to parse again on each execution.
This library provides a simple pagination implementation for using in template. See page package and the example.