timplit

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(templateText []byte, d *Data) ([]byte, error)

Execute applies the data to the template.

func ExecuteJSON added in v0.2.0

func ExecuteJSON(templateText []byte, jsonText []byte) ([]byte, error)

ExecuteJSON applies the raw JSON text to the template.

func ExecuteYAML added in v0.2.0

func ExecuteYAML(templateText []byte, yamlText []byte) ([]byte, error)

ExecuteYAML applies the raw YAML text (a single document) to the template.

Types

type Data

type Data interface{}

Data is the JSON/YAML will be unmarshaled into this type, then applied to the template.

type Timplit added in v0.2.0

type Timplit struct {
	Template          io.Reader
	Data              io.Reader
	Out               io.Writer
	Err               io.Writer
	IgnoreParseErrors bool
}

func (*Timplit) JSON added in v0.2.0

func (t *Timplit) JSON() error

JSON reads a single JSON document from an io.Reader (usually stdin) until EOF, executes the template, and writes the result to an io.Writer (usually stdout). The template is always read first in full, and blocks until EOF is reached.

If t.IgnoreParseErrors is true, then errors will be printed but execution will continue. Otherwise, the first error encountered is returned and subsequent lines will not be read.

func (*Timplit) MultipartJSON added in v0.2.0

func (t *Timplit) MultipartJSON() error

MultipartJSON reads one JSON document per line from an io.Reader (usually stdin), executes the template for each line, and writes the result to an io.Writer (usually stdout). The template is always read first in full, and blocks until EOF is reached.

If t.IgnoreParseErrors is true, then errors will be printed but execution will continue. Otherwise, the first error encountered is returned and subsequent lines will not be read.

func (*Timplit) YAML added in v0.2.0

func (t *Timplit) YAML() error

YAML executes the template for each YAML document (separated by "---") it reads from an io.Reader (usually stdin) and writes the result to an io.Writer (usually stdout). The template is always read first in full, and blocks until EOF is reached.

If t.IgnoreParseErrors is true, then errors will be printed but execution will continue. Otherwise, the first error encountered is returned and subsequent lines will not be read.

Jump to

Keyboard shortcuts

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