tmpl

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NVariable
)

Variables

This section is empty.

Functions

func Inspect

func Inspect(node parse.Node, f func(parse.Node) bool)

func Walk

func Walk(v Visitor, node parse.Node)

Types

type Inspector

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

func (*Inspector) Nodes

func (in *Inspector) Nodes(types []parse.Node, f func(n parse.Node, push bool) (proceed bool))

func (*Inspector) Preorder

func (in *Inspector) Preorder(types []parse.Node, f func(parse.Node))

func (*Inspector) WithStack

func (in *Inspector) WithStack(types []parse.Node, f func(n parse.Node, push bool, stack []parse.Node) (proceed bool))

type Keyword

type Keyword struct {
	Name        string
	IDToken     etype.Token
	SingularPos int
	PluralPos   int
	ContextPos  int
	DomainPos   int
}

func DefaultKeywords

func DefaultKeywords(name string, isMonolingual bool) []*Keyword

func ParseKeywords

func ParseKeywords(spec string, isMonolingual bool) (*Keyword, error)

func (*Keyword) MaxPosition added in v0.4.0

func (k *Keyword) MaxPosition() int

type Template

type Template struct {
	Filename  string
	Trees     map[string]*parse.Tree
	Inspector *Inspector

	// GoFilePos holds the position from which .go file the template originates
	GoFilePos token.Position

	// OffsetLookup holds the first position of all line starts.
	OffsetLookup []token.Position

	// Comments holds the comments of each line number
	Comments map[int][]string
}

func Parse

func Parse(filepath string) (*Template, error)

func ParseBytes

func ParseBytes(name string, src []byte) (*Template, error)

func ParseString

func ParseString(name, content string) (*Template, error)

func (*Template) ExtractComments added in v0.4.0

func (t *Template) ExtractComments()

func (*Template) GetComments added in v0.4.0

func (t *Template) GetComments(offset parse.Pos) []string

func (*Template) Position added in v0.4.0

func (t *Template) Position(offset parse.Pos) token.Position

type Visitor

type Visitor interface {
	Visit(node parse.Node) (w Visitor)
}

Jump to

Keyboard shortcuts

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