template

package
v0.0.0-...-947b840 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuiltInFuncs

func BuiltInFuncs() template.FuncMap

func Populate

func Populate(t TextTemplate) (string, error)

Populate populates the template and returns it as a string.

func PopulateFrom

func PopulateFrom(t Template, path string) (string, error)

PopulateFrom reads the template from a given path and returns the populated template as a string.

func TrimTemplate

func TrimTemplate(s string) string

TrimTemplate trims alls leading and trailing spaces from each line and replace tabs with double space.

func Write

func Write(t TextTemplate, path string) error

Write populates the template and writes it to the given path.

func WriteFrom

func WriteFrom(t Template, srcPath string, dstPath string) error

WriteFrom reads a template from source path, populates the template and writes it to the destination path.

Types

type CustomDelimiters

type CustomDelimiters interface {
	Delimiters() (left string, right string)
}

If a type implements the Delimiters method, it can specify custom delimiters that will replace the default ones.

type CustomFunctions

type CustomFunctions interface {
	Functions() map[string]any
}

If a type implements the Functions method, it can provide custom functions that will be added to the existing built-in functions.

type Template

type Template interface {
	Name() string
}

type TextTemplate

type TextTemplate interface {
	Template
	Template() string
}

Jump to

Keyboard shortcuts

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