template

package
v0.0.0-...-e537141 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BufferedParse

func BufferedParse(eng MutEngine, fsys fs.FS, name, path string) (err error)

func ParseFromPaths

func ParseFromPaths(eng MutEngine, ctx ParseContext, parser ParserFn) (err error)

func RenderBackground

func RenderBackground(e Engine, cfg Config) (err error)

Types

type BufferedEngine

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

BufferedEngine first renders the template into a ReadWriter. If rendering is successful the contents of the ReadWriter will be copied into the Writer passed to the Render call.

func NewBufferedEngine

func NewBufferedEngine(e Engine, p pool.Bufio) (b BufferedEngine)

func (BufferedEngine) Render

func (b BufferedEngine) Render(ctx context.Context, cfg Config) (err error)

type BufferedExecutor

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

func NewBufferedExecutor

func NewBufferedExecutor() (b BufferedExecutor)

func (BufferedExecutor) ExecuteTemplates

func (b BufferedExecutor) ExecuteTemplates(eng Engine, ctx ExecuteContext) (err error)

type BundleMethods

type BundleMethods struct {
	Includer Includer
}

type BundlerBuilder

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

func NewBuilder

func NewBuilder(fsys fs.FS) (bb BundlerBuilder)

func (BundlerBuilder) BuildMethods

func (bb BundlerBuilder) BuildMethods() (m BundleMethods)

func (*BundlerBuilder) SetLog

func (bb *BundlerBuilder) SetLog(log zerolog.Logger)

type Config

type Config struct {
	Out      io.Writer
	Values   Values
	Template Template
}

Context is the template context. Contains external information.

type Engine

type Engine interface {
	Render(context.Context, Config) error
}

Engine represents is a generic object for rendering templates.

type ExecuteConfig

type ExecuteConfig struct {
	Values Values
	Paths  Paths
}

type ExecuteContext

type ExecuteContext struct {
	Values Values
	Paths  Paths
	Fsys   fs.FS
}

type Executor

type Executor interface {
	ExecuteTemplates(eng Engine, ctx ExecuteContext) (err error)
}

type FsysInclude

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

func (FsysInclude) IncludeInto

func (f FsysInclude) IncludeInto(path string, w io.Writer) (err error)

type FuncMap

type FuncMap = template.FuncMap

type HTML

type HTML = template.HTML

type HTMLAttr

type HTMLAttr = template.HTMLAttr

type HTMLBundler

type HTMLBundler interface {
	BundleHTML(r io.Reader, w io.Writer) (err error)
}

type IncludeFunc

type IncludeFunc func(s string) (contents string, err error)

type Includer

type Includer interface {
	IncludeInto(s string, w io.Writer) (err error)
}

type Iter

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

func IterStart

func IterStart(low int) (it Iter)

func (Iter) Build

func (it Iter) Build() (s []int, err error)

func (Iter) High

func (it Iter) High(high int) (i Iter)

func (Iter) Step

func (it Iter) Step(step int) (i Iter)

type Kind

type Kind int

ENUM(

String
ID

)

const (
	// KindString is a Kind of type String.
	KindString Kind = iota
	// KindID is a Kind of type ID.
	KindID
)

func ParseKind

func ParseKind(name string) (Kind, error)

ParseKind attempts to convert a string to a Kind.

func (Kind) AsTemplate

func (k Kind) AsTemplate(IdOrTpl string) Template

func (Kind) MarshalText

func (x Kind) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (Kind) String

func (x Kind) String() string

String implements the Stringer interface.

func (*Kind) UnmarshalText

func (x *Kind) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type Loader

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

func (Loader) Abs

func (l Loader) Abs(base, name string) (s string)

func (Loader) Get

func (l Loader) Get(path string) (r io.Reader, err error)

type LogIncluder

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

func (LogIncluder) IncludeInto

func (l LogIncluder) IncludeInto(path string, w io.Writer) (err error)

type Manager

type Manager struct {
	Fsys   fs.MutFS
	Parser ParserFn
	Exec   Executor
}

func (Manager) Execute

func (m Manager) Execute(eng Engine, cfg ExecuteConfig) (err error)

func (Manager) Setup

func (m Manager) Setup(eng MutEngine, cfg SetupConfig) (err error)

type MutEngine

type MutEngine interface {
	Engine
	ParseTemplate(name string, content io.Reader) (err error)
	SetFuncs(funcs template.FuncMap) (err error)
}

type ParseContext

type ParseContext struct {
	Paths Paths
	Fsys  fs.FS
}

type Parser

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

func NewParser

func NewParser(bpool pool.Bufio, log zerolog.Logger) (p Parser)

func (Parser) Parse

func (p Parser) Parse(eng MutEngine, fsys fs.FS, name, path string) (err error)

type ParserFn

type ParserFn func(eng MutEngine, fsys fs.FS, name, path string) (err error)

type Paths

type Paths map[string]string

type PongoEngine

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

func EmptyPongoEngine

func EmptyPongoEngine() PongoEngine

func (PongoEngine) GetTemplate

func (pg PongoEngine) GetTemplate(template string) (*pongo.Template, error)

func (PongoEngine) ParseTemplate

func (pg PongoEngine) ParseTemplate(name string, content io.Reader) (err error)

func (PongoEngine) Render

func (pg PongoEngine) Render(ctx context.Context, cfg Config) (err error)

func (PongoEngine) SetFuncs

func (pg PongoEngine) SetFuncs(funcs FuncMap) error

type ReadWriterPool

type ReadWriterPool interface {
	GetReadWriter() io.ReadWriter
	PutReadWriter(io.ReadWriter)
}

ReadWriterPool represents a generic pool for ReadWriter objects.

type SetupConfig

type SetupConfig struct {
	Sources Paths
	Funcs   template.FuncMap
}

type StdLibHtmlEngine

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

func EmptyStdHtmlEngine

func EmptyStdHtmlEngine() (s StdLibHtmlEngine)

func StdHtmlEngineFromTpls

func StdHtmlEngineFromTpls(tpls *template.Template) (s StdLibHtmlEngine)

func (*StdLibHtmlEngine) GetTemplate

func (s *StdLibHtmlEngine) GetTemplate(tpl string) (*template.Template, error)

func (StdLibHtmlEngine) HasTemplate

func (s StdLibHtmlEngine) HasTemplate(name string) (*template.Template, bool)

func (*StdLibHtmlEngine) ParseTemplate

func (s *StdLibHtmlEngine) ParseTemplate(name string, content io.Reader) (err error)

func (*StdLibHtmlEngine) Render

func (s *StdLibHtmlEngine) Render(ctx context.Context, cfg Config) (err error)

func (*StdLibHtmlEngine) SetFuncs

func (s *StdLibHtmlEngine) SetFuncs(funcs template.FuncMap) (err error)

func (*StdLibHtmlEngine) UniqueName

func (s *StdLibHtmlEngine) UniqueName(tpl string) string

type StdLibTextEngine

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

func EmptyStdTextEngine

func EmptyStdTextEngine() (s StdLibTextEngine)

func StdTextEngineFromTpls

func StdTextEngineFromTpls(tpls *template.Template) (s StdLibTextEngine)

func (*StdLibTextEngine) GetTemplate

func (s *StdLibTextEngine) GetTemplate(tpl string) (*template.Template, error)

func (StdLibTextEngine) HasTemplate

func (s StdLibTextEngine) HasTemplate(name string) (*template.Template, bool)

func (*StdLibTextEngine) ParseTemplate

func (s *StdLibTextEngine) ParseTemplate(name string, content io.Reader) (err error)

func (*StdLibTextEngine) Render

func (s *StdLibTextEngine) Render(ctx context.Context, cfg Config) (err error)

func (*StdLibTextEngine) SetFuncs

func (s *StdLibTextEngine) SetFuncs(funcs FuncMap) (err error)

func (*StdLibTextEngine) UniqueName

func (s *StdLibTextEngine) UniqueName(tpl string) string

type Template

type Template struct {
	IdOrTpl string
	Kind    Kind
}

func (Template) ToConfig

func (t Template) ToConfig(out io.Writer, vals Values) Config

type Values

type Values map[string]interface{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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