百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

stick

> 编程语言
开源

Twig 模板引擎的 Golang 端口

198 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Twig 模板引擎的 Golang 端口

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/template and html/template from the Go standard library.
  • pongo2 is 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

  • 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

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Gogogolangsticktemplate-engine

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言