render

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TemplateDirectory

func TemplateDirectory(props props.Pairs, source, destination string) error

TemplateDirectory renders a given source template using props as variables into a given destination. Destination must not exist. Calling this function is the same as calling TemplateDirectoryOpts without options.

func TemplateDirectoryOpts added in v0.2.6

func TemplateDirectoryOpts(props props.Pairs, source, destination string, opts *Options) error

TemplateDirectoryOpts renders a given source template into a given destination using props as variables and an optional Options structure. Destination must not exist.

Types

type AfterRenderCallback added in v0.2.6

type AfterRenderCallback func(info os.FileInfo, contents string) (string, error)

AfterRenderCallback defines a callback function to be called whenever a new file has been rendered and is about to be written to disk. This function can perform any kind of modification to `contents`, and return those modifications, which will then be written to disk. Info contains a os.FileInfo structure representing the source template, while contents contains the rendered template.

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

func NewExecutor

func NewExecutor(props props.Pairs) *Executor

NewExecutor returns a new Executor using provided props.Pairs

func (*Executor) Exec

func (e *Executor) Exec(tree lexer.AST) (string, error)

Exec takes a given AST and renders using props passed to the current Executor. Either returns a rendered string, or an error.

type Helper

type Helper func(string) string

type Options added in v0.2.6

type Options struct {
	AfterRenderCallback AfterRenderCallback
}

Jump to

Keyboard shortcuts

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