More Premium Hugo Themes Premium Html Themes

Fet

A golang template engine that can compile code into `html/template`, use syntax like the php template engine smarty.

Fet

A golang template engine that can compile code into `html/template`, use syntax like the php template engine smarty.

Author Avatar Theme by fefit
Github Stars Github Stars: 28
Last Commit Last Commit: Mar 21, 2023 -
First Commit Created: Jun 19, 2023 -
Fet screenshot

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:

  1. Install the FET package using the following command:
go get github.com/fetlang/fet
  1. Import the FET package in your Go code:
import "github.com/fetlang/fet"
  1. Use the FET template engine by creating a new instance:
fet := fet.New(nil)
  1. Compile a template file using the Compile method:
result, err := fet.Compile("template.tpl", false)
  1. Display the rendered HTML code using the Display method:
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.