Overview
FET is a golang template engine that translates smarty-like template code into golang html/template. The name FET stands for Friendly, Easily for Template code. While the official golang package html/template is a fully functional template engine, it has some defects in terms of user experience, and FET aims to improve upon these issues.
Features
- Expression logics
- Use include with defined variable scopes
- Use extends to inherit base template with defined variable scopes
- Limited support for for and capture
Installation
To install the FET template engine, you can follow these steps:
- Install the FET package using the following command:
go get github.com/fetlang/fet
- Import the FET package in your Go code:
import "github.com/fetlang/fet"
- Use the FET template engine by creating a new instance:
fet := fet.New(nil)
- Compile a template file using the
Compilemethod:
result, err := fet.Compile("template.tpl", false)
- Display the rendered HTML code using the
Displaymethod:
err := fet.Display("template.tpl", data, output)
Summary
FET is a golang template engine that aims to improve upon the user experience of the official html/template package. It provides features such as expression logics, variable scopes, and support for inheritance and loops. By using FET, developers can easily translate smarty-like template code into golang html/templates.