github.com/tyler-sommer/stick (go): Package stick is a Go language port of the Twig templating engine.  Stick executes Twig templates and allows users to define custom Functions, Filters, and Tests. The parser allows parse-time node inspection with NodeVisitors, and a template Loader to load named templates from any source.  Stick itself is a parser and template executor. If you're looking for Twig compatibility, check out package https://pkg.go.dev/github.com/tyler-sommer/stick/twig  For additional information on Twig, check http://twig.sensiolabs.org/  Obligatory "Hello, World!" example:  Another example, using a FilesystemLoader and responding to an HTTP request:  Any user value in Stick is represented by a stick.Value. There are three main types in Stick when it comes to built-in operations: strings, numbers, and booleans. Of note, numbers are represented by float64 as this matches regular Twig behavior most closely.  Stick makes no restriction on what is stored in a stick.Value, but some built-in operators will try to coerce a value into a boolean, string, or number depending on the operation.  Additionally, custom types that implement specific interfaces can be coerced. Stick defines three interfaces: Stringer, Number, and Boolean. Each interface defines a single method that should convert a custom type into the specified type.  On a final note, there exists three functions to coerce any type into a string, number, or boolean, respectively.  It is possible to define custom Filters, Functions, and boolean Tests available to your Stick templates. Each user-defined type is simply a function with a specific signature.  A Func represents a user-defined function.  Functions can be called anywhere expressions are allowed. Functions may take any number of arguments.  A Filter is a user-defined filter.  Filters receive a value and modify it in some way. Filters also accept zero or more arguments beyond the value to be filtered.  A Test represents a user-defined boolean test.  Tests are used to make some comparisons more expressive. Tests also accept zero to any number of arguments, and Test names can contain up to one space.  User-defined types are added to an Env after it is created. For example:
Keywords: go|golang|stick|template-engine|twig