template

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package template holds utilities for working with templates.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingStorage represents error when storage with data is missing
	ErrMissingStorage = errors.New("missing storage")

	// ErrMissingStorageValue represents error when storage doesn't have required data in it
	ErrMissingStorageValue = errors.New("missing storage value")
)

Functions

This section is empty.

Types

type Engine added in v0.9.3

type Engine interface {
	// Replace replaces template values using provided storage.
	Replace(templateValue string, storage map[string]any) (string, error)
}

Engine is entity that has ability to work with templates.

type TemplateManager

type TemplateManager struct{}

TemplateManager is entity that has ability to manage templates.

func New

func New() TemplateManager

func (TemplateManager) Replace

func (tm TemplateManager) Replace(templateValue string, storage map[string]any) (string, error)

Replace replaces template values using provided storage. templateValue should exist between two brackets {{ }} preceded with dot, for example: "my name is: {{.NAME}}".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL