document

package
v0.0.0-...-1ecfe31 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrArchive = errors.New("archiveErr")
View Source
var ErrMimetype = errors.New("mimetypeErr")
View Source
var ErrOverride = errors.New("overrideErr")
View Source
var ErrUnknownType = errors.New("unknownTypeErr")

TODO: Better error description and use it in Go style.

Functions

This section is empty.

Types

type Format

type Format interface {
	MIMEType() string                  // Returns the mimetype of the document
	Open(name string) (fs.File, error) // Opens a file inside the package
	InitScript() string                // Returns the initialization script for the engine
}

Format needs to be implemented by templateable documents.

type Model

type Model struct {
	Data     map[string]any
	Metadata map[string]string
}

Model defines the data that is passed to the engine for templating. Passed data must be a primitive or a map.

type PackagedDocument

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

PackageDocument represents a templateable document.

func NewFromFile

func NewFromFile(path string) (*PackagedDocument, error)

NewFromFile returns a new packaged document instance for the given file path. TODO: make this factory function smarter and not only check the file extension, but also the MIME type of the file.

func (*PackagedDocument) Write

func (p *PackagedDocument) Write(model *Model, out io.Writer) (*ProcessingData, error)

Write runs the packaged document through the templating engine using the given model and writes a new packaged document on the writer.

type ProcessingData

type ProcessingData struct {
	// Data of template
	TemplateMimeType    string
	TemplateXMLTree     *xmltree.Node
	TemplateLuaProg     string
	TemplateInitScript  string
	TemplateLuaNodeList []*xmltree.Node

	// Processed data
	LuaExecTrace []string
	XMLResult    string
}

Jump to

Keyboard shortcuts

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