Stick
A golang port of the Twig templating engine
Install / Use
/learn @tyler-sommer/StickREADME
Stick
A Go language port of the Twig templating engine.
Overview
This project is split across two parts.
Package
github.com/tyler-sommer/stick
is a Twig template parser and executor. It provides the core
functionality and offers many of the same extension points as Twig like
functions, filters, node visitors, etc.
Package
github.com/tyler-sommer/stick/twig
contains extensions to provide the most Twig-like experience for
template writers. It aims to feature the same functions, filters, etc.
to be closely Twig-compatible.
Current status
Stable, mostly feature complete
Stick itself is mostly feature-complete, with the exception of whitespace control, and better error handling in places.
Stick is made up of three main parts: a lexer, a parser, and a template executor. Stick's lexer and parser are complete. Template execution is under development, but essentially complete.
See the to do list for additional information.
Alternatives
These alternatives are worth checking out if you're considering using Stick.
text/templateandhtml/templatefrom the Go standard library.pongo2is a full-featured Go language port of Django's templating language.
Installation
Stick is intended to be used as a library. The recommended way to install the library is using go get.
go get -u github.com/tyler-sommer/stick
Usage
Execute a simple Stick template.
package main
import (
"log"
"os"
"github.com/tyler-sommer/stick"
)
func main() {
env := stick.New(nil)
if err := env.Execute("Hello, {{ name }}!", os.Stdout, map[string]stick.Value{"name": "Tyler"}); err != nil {
log.Fatal(err)
}
}
See godoc for more information.
To do
- [x] Autoescaping (see: Twig compatibility)
- [ ] Whitespace control
- [ ] Improve error reporting
Further
- [ ] Improve test coverage (especially error cases)
- [ ] Custom operators and tags
- [ ] Sandbox
- [ ] Generate native Go code from a given parser tree
Related Skills
node-connect
346.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
346.4kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
107.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
