Categorygithub.com/nathan-osman/pongo2-embed-loader/v4
modulepackage
4.0.1
Repository: https://github.com/nathan-osman/pongo2-embed-loader.git
Documentation: pkg.go.dev

# README

pongo2-embed-loader

Build Status Coverage Status Go Report Card Go Reference MIT License

pongo2 provides Django-like templates for Go applications. However, it does not provide native support for the new embed directive introduced in Go 1.16. This package aims to fill that gap by providing a TemplateLoader for embedded files.

Usage

The package is extremely easy to use.

Assuming you have a directory named templates in the current source directory, you can create a template set with:

import "github.com/nathan-osman/pongo2-embed-loader"

//go:embed templates/*
var content embed.FS

templateSet := pongo2.NewSet("", &loader.Loader{Content: content})

You can then retrieve a template with:

t, err := templateSet.FromFile("templates/file.tpl")

# Structs

Loader implements pongo2's TemplateLoader interface for templates stored in a fs.FS (such as an embed.FS).