templ

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2025 License: BSD-3-Clause Imports: 6 Imported by: 6

README

templ

Static typed templating for go without logic

templ works with go >= 1.23.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	*bytes.Buffer
	// contains filtered or unexported fields
}

a named buffer, fullfills the Setter interface

func (*Buffer) Name

func (b *Buffer) Name() string

type Escaper

type Escaper map[string]func(interface{}) string

func (Escaper) View

func (esc Escaper) View(stru interface{}, tag string) *View

type Position added in v0.4.0

type Position struct {
	Value   string
	Escaper []func(interface{}) string
	// contains filtered or unexported fields
}

func NewPosition added in v0.4.0

func NewPosition(name string, escaper ...func(interface{}) string) Position

func (Position) Escape added in v0.4.0

func (p Position) Escape(escaper ...func(interface{}) string) Position

func (Position) Name added in v0.4.0

func (p Position) Name() string

func (Position) Set added in v0.4.0

func (p Position) Set(val interface{}) Setter

func (Position) Setf added in v0.4.0

func (p Position) Setf(format string, vals ...interface{}) Setter

func (Position) WriteTo added in v0.4.0

func (p Position) WriteTo(w io.Writer) (int64, error)

type Setter

type Setter interface {
	io.WriterTo
	Name() string
}

type Template

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

func New

func New(name string) *Template

func (*Template) Add

func (t *Template) Add(data ...interface{}) (err error)

func (*Template) MustAdd

func (t *Template) MustAdd(data ...interface{}) *Template

add data to the template

func (*Template) MustParse

func (t *Template) MustParse() *Template

func (*Template) MustWrite

func (t *Template) MustWrite(b []byte)

func (*Template) MustWriteByte

func (t *Template) MustWriteByte(b byte)

func (*Template) MustWriteRune

func (t *Template) MustWriteRune(r rune)

func (*Template) MustWriteSetter

func (t *Template) MustWriteSetter(s Setter)

func (*Template) MustWriteString

func (t *Template) MustWriteString(s string)

func (*Template) MustWriteTo

func (t *Template) MustWriteTo(w io.Writer)

func (*Template) New

func (t *Template) New() *Buffer

func (*Template) Parse

func (t *Template) Parse() error

func (*Template) Replace

func (r *Template) Replace(setters ...Setter) *Buffer

func (*Template) ReplaceMixed

func (r *Template) ReplaceMixed(mixed ...interface{}) *Buffer

func (*Template) ReplaceMixedTo

func (r *Template) ReplaceMixedTo(wr io.Writer, mixed ...interface{})

func (*Template) ReplaceTo

func (r *Template) ReplaceTo(wr io.Writer, setters ...Setter)

func (*Template) WriteSetter

func (t *Template) WriteSetter(p Setter) (err error)

type View

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

func (*View) HasPosition added in v0.4.0

func (str *View) HasPosition(field string) bool

func (*View) Position added in v0.4.0

func (str *View) Position(field string) Position

func (*View) Set

func (str *View) Set(stru interface{}) (ss []Setter)

func (*View) Tag

func (str *View) Tag() string

func (*View) Type

func (str *View) Type() string

Directories

Path Synopsis
examples
sub

Jump to

Keyboard shortcuts

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