core

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TmplhateFuncs = template.FuncMap{
	"lower": func(s string) string {
		return cases.Lower(language.English).String(s)
	},
	"upper": func(s string) string {
		return cases.Upper(language.English).String(s)
	},
	"mul": func(a int, b int) int {
		return a * b
	},
}

flags

Functions

func FromStdin

func FromStdin() bool

START Global helpers helper: check if input is stdin

func Read

func Read(r io.Reader) []byte

helper: in = reader, out = bytes

Types

type Tmplhate

type Tmplhate struct {
	Caser         cases.Caser
	Language      language.Tag
	NormalizeVars bool
	String        string
	Tmpl          *template.Template
	Vars          map[string]any `yaml:"vars,omitempty,flow"`
	VarsCase      string
}

impl of tmplhate interface

func (*Tmplhate) GetReader

func (t *Tmplhate) GetReader(location string) io.Reader

START Tmplhate methods method to get template from input source

func (*Tmplhate) Init

func (t *Tmplhate) Init(tmplLocation string, varsLocation string, dontNormalize bool, varsCase string)

func (*Tmplhate) LoadCaser

func (t *Tmplhate) LoadCaser()

method to set a cases.Caser

func (*Tmplhate) LoadEnvVars

func (t *Tmplhate) LoadEnvVars()

method to load env vars into object

func (*Tmplhate) LoadTemplate

func (t *Tmplhate) LoadTemplate(r io.Reader)

method to get template from reader and load

func (*Tmplhate) LoadVars

func (t *Tmplhate) LoadVars(r io.Reader)

method to load variables into object

func (*Tmplhate) ValidateTemplate

func (t *Tmplhate) ValidateTemplate()

helper: validate template

func (*Tmplhate) WriteTemplate

func (t *Tmplhate) WriteTemplate(w io.Writer)

method to output rendered template to io.Writer

type Tmplhater

type Tmplhater interface {
	LoadVars(io.Reader, bool, string)
	ReadTemplate(io.Reader)
	Write(io.Writer) error
	ValidateTemplate() error
}

interface for tmplhate

Jump to

Keyboard shortcuts

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