https://github.com/mawngo/go-tmpls
Template caching and utilities for go
https://github.com/mawngo/go-tmpls
cache golang pagination template template-cache
Last synced: over 1 year ago
JSON representation
Template caching and utilities for go
- Host: GitHub
- URL: https://github.com/mawngo/go-tmpls
- Owner: mawngo
- License: mit
- Created: 2024-09-07T18:11:14.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2025-03-07T12:12:58.000Z (over 1 year ago)
- Last Synced: 2025-03-07T12:27:45.373Z (over 1 year ago)
- Topics: cache, golang, pagination, template, template-cache
- Language: Go
- Homepage:
- Size: 93.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go Templates
Template caching and paging utilities. Require go 1.22+
## Usage
```shell
go get github.com/mawngo/go-tmpls
```
## Template Caching
Cache the template for re-execution without having to parse it again, support template reload for development.
See [examples](/examples/main.go) for setup and integrating template cache.
### Built-in template funcs
By default, this library adds some [helpers](/internal/builtin.go) to the template.
To disable all built-in functions use`WithoutBuiltins()`, or `WithoutBuiltins('fn1', 'fn2', ...)` to disable specific
function.
You can add custom funcs using `WithFuncs`.
### Custom cache
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.
### No cache
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.
## Pagination
This library provides a simple pagination implementation for using in template.
See [page](/page) package and the [example](/examples).