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.
stick/twig
2023-04-01 19:03:44 -06:00
..
escape Apply goimports to remaining sources 2020-10-08 15:03:03 -06:00
filter Add the url_encode filter (#50) 2021-11-18 06:09:54 -07:00
escape.go Fix template format guessing in auto escaper 2023-04-01 19:02:24 -06:00
escape_test.go Fix template format guessing in auto escaper 2023-04-01 19:02:24 -06:00
README.md Fix CI badge in twig/README 2023-04-01 19:03:44 -06:00
twig_compat.go Update formatting in doc comments 2023-03-29 19:26:42 -06:00

Twig

CircleCI GoDoc

Provides Twig-compatibility for the stick templating engine.

Overview

This is the Twig compatibility subpackage for Stick.

Current status

In development

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.

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.

Installation

The twig package 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/twig

Usage

Execute a simple Twig template.

package main

import (
	"log"
	"os"
	
	"github.com/tyler-sommer/stick"
	"github.com/tyler-sommer/stick/twig"
)

func main() {
    env := twig.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.