tplx

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package tplx implements data-driven templates for generating ooxml files.

Index

Constants

View Source
const (
	DOCX = ".docx"
	XLSX = ".xlsx"
	PPTX = ".pptx"
)

File types.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rel

type Rel struct {
	Type   string `xml:"Type,attr"`
	Target string `xml:"Target,attr"`
}

Rel represents a rel.

type Rels

type Rels struct {
	XMLName xml.Name
	Rels    []Rel `xml:"Relationship"`
}

Rels represents the rels.

func (*Rels) Find

func (a *Rels) Find(typ string) (targets []string)

Find finds the targets by type.

type Template

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

Template is the representation of a parsed template.

func New

func New() *Template

New creates a new template.

func (*Template) ExecuteBytes

func (a *Template) ExecuteBytes(data any) ([]byte, error)

ExecuteBytes applies a parsed template to the specified data object, and return as bytes.

func (*Template) ExecuteFile

func (a *Template) ExecuteFile(name string, data any) error

ExecuteFile applies a parsed template to the specified data object, and writes the output to the file.

func (*Template) ExecuteWriter

func (a *Template) ExecuteWriter(w io.Writer, data any) error

ExecuteWriter applies a parsed template to the specified data object, and writes the output to the writer.

func (*Template) ExecuteZIP

func (a *Template) ExecuteZIP(zw *zip.Writer, data any) error

ExecuteZIP applies a parsed template to the specified data object, and writes the output to the zip writer.

func (*Template) Funcs

func (a *Template) Funcs(funcs map[string]any) *Template

Funcs adds the elements of the argument map to the template's function map.

func (*Template) ParseBytes

func (a *Template) ParseBytes(ftype Type, bs []byte) error

ParseBytes parses the bytes as a template.

func (*Template) ParseFile

func (a *Template) ParseFile(name string) error

ParseFile parses the file as a template.

func (*Template) ParseReader

func (a *Template) ParseReader(ftype Type, r io.Reader) error

ParseReader parses the reader as a template.

func (*Template) ParseZIP

func (a *Template) ParseZIP(ftype Type, zr *zip.Reader) error

ParseZIP parses the zip reader as a template.

type Type

type Type string

Type repesents the file type.

Jump to

Keyboard shortcuts

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