This repository has been archived on 2024-02-28. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
2023-05-25 09:53:14 +02:00
.circleci Add go1.19 and go1.20 to CI 2023-03-29 19:23:19 -06:00
parse Made token values pointers in lexer/parser 2023-05-25 09:52:54 +02:00
testdata Add parent built-in function (#27) 2020-02-04 16:58:39 -07:00
twig Fix CI badge in twig/README 2023-04-01 19:03:44 -06:00
doc.go Update formatting in doc comments 2023-03-29 19:26:42 -06:00
example_fs_test.go Extracted Twig-compatible extensions into twig subpackage. 2016-09-27 13:46:43 -06:00
example_macro_test.go Extracted Twig-compatible extensions into twig subpackage. 2016-09-27 13:46:43 -06:00
example_parent_test.go Add parent built-in function (#27) 2020-02-04 16:58:39 -07:00
example_test.go Fix default case handling in walkChild 2023-04-07 21:59:24 -06:00
exec.go Fix default case handling in walkChild 2023-04-07 21:59:24 -06:00
exec_test.go Refactor exec tests further 2023-03-31 23:59:16 -06:00
go.mod Change go.mod name 2023-05-25 09:53:14 +02:00
go.sum Update shopspring/decimal 2023-04-07 21:43:43 -06:00
LICENSE Added LICENSE 2014-09-01 22:59:32 -07:00
loader.go Added MemoryLoader and test. 2016-05-05 01:08:12 -06:00
loader_test.go Added MemoryLoader and test. 2016-05-05 01:08:12 -06:00
README.md Update README 2023-04-01 00:23:28 -06:00
stick.go Add ExecuteSafe for avoiding partial output if an error occurs 2023-04-07 21:37:32 -06:00
value.go Add all loop variables inside a loop (#49) 2021-10-18 08:34:37 -06:00
value_test.go Apply goimports to remaining sources 2020-10-08 15:03:03 -06:00

Stick

CircleCI GoDoc

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.

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

Further