xpand

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 9 Imported by: 0

README

xpand - A tiny text/template expander

Go Reference test codecov

Installation

go get github.com/m0t0k1ch1-go/xpand

Documentation

Index

Constants

View Source
const (
	SchemeRaw = "raw"
	SchemeEnv = "env"
)
View Source
const (
	DefaultLeftDelim  = "{{"
	DefaultRightDelim = "}}"
)

Variables

This section is empty.

Functions

func File

func File(ctx context.Context, path string, opts ...Option) ([]byte, error)

File reads the file at path, expands it as a text/template, and returns the result.

Types

type Option

type Option func(*options)

Option configures the expansion.

func WithDelims

func WithDelims(left, right string) Option

WithDelims sets the action delimiters. Empty values stand for the defaults.

func WithResolver added in v1.3.0

func WithResolver(scheme string, resolver Resolver) Option

WithResolver registers the resolver for the scheme. It overrides the resolver already registered for the same scheme, including the built-in ones.

type Resolver added in v1.3.0

type Resolver func(ctx context.Context, key string) (string, bool, error)

Resolver resolves the value for key. The second return value reports whether the value was resolved.

Jump to

Keyboard shortcuts

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