ego: github.com/benbjohnson/ego Index | Files | Directories

package ego

import "github.com/benbjohnson/ego"

Index

Package Files

ego.go parse.go scanner.go

func AttrNames Uses

func AttrNames(attrs map[string]interface{}) []string

AttrNames returns a sorted list of names for an attribute set.

type Attr Uses

type Attr struct {
    Name    string
    NamePos Pos

    Value    string
    ValuePos Pos
}

Attr represents a key/value passthrough pair on a component.

type AttrEndBlock Uses

type AttrEndBlock struct {
    Pos     Pos
    Package string
    Name    string
}

AttrEndBlock represents the closing block of an ego component attribute.

func (*AttrEndBlock) Namespace Uses

func (blk *AttrEndBlock) Namespace() string

Namespace returns the block package, if defined. Otherwise returns "ego".

type AttrStartBlock Uses

type AttrStartBlock struct {
    Pos     Pos
    Package string
    Name    string
    Yield   []Block
}

AttrStartBlock represents the opening block of an ego component attribute.

func (*AttrStartBlock) Namespace Uses

func (blk *AttrStartBlock) Namespace() string

Namespace returns the block package, if defined. Otherwise returns "ego".

type Block Uses

type Block interface {
    // contains filtered or unexported methods
}

Block represents an element of the template.

type CodeBlock Uses

type CodeBlock struct {
    Pos     Pos
    Content string
}

CodeBlock represents a Go code block that is printed as-is to the template.

type ComponentEndBlock Uses

type ComponentEndBlock struct {
    Pos     Pos
    Package string
    Name    string
}

ComponentEndBlock represents the closing block of an ego component.

func (*ComponentEndBlock) Namespace Uses

func (blk *ComponentEndBlock) Namespace() string

Namespace returns the block package, if defined. Otherwise returns "ego".

type ComponentStartBlock Uses

type ComponentStartBlock struct {
    Pos        Pos
    Package    string
    Name       string
    Closed     bool
    Fields     []*Field
    Attrs      []*Attr
    AttrBlocks []*AttrStartBlock
    Yield      []Block
}

ComponentStartBlock represents the opening block of an ego component.

func (*ComponentStartBlock) Namespace Uses

func (blk *ComponentStartBlock) Namespace() string

Namespace returns the block package, if defined. Otherwise returns "ego".

type Field Uses

type Field struct {
    Name    string
    NamePos Pos

    Value    string
    ValuePos Pos
}

Field represents a key/value pair on a component.

type Pos Uses

type Pos struct {
    Path   string
    LineNo int
}

Pos represents a position in a given file.

func Position Uses

func Position(blk Block) Pos

Position returns the position of the block.

type PrintBlock Uses

type PrintBlock struct {
    Pos     Pos
    Content string
}

PrintBlock represents a block that will HTML escape the contents before outputting

type RawPrintBlock Uses

type RawPrintBlock struct {
    Pos     Pos
    Content string
}

RawPrintBlock represents a block of the template that is printed out to the writer.

type Scanner Uses

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

Scanner is a tokenizer for ego templates.

func NewScanner Uses

func NewScanner(r io.Reader, path string) *Scanner

NewScanner initializes a new scanner with a given reader.

func (*Scanner) Scan Uses

func (s *Scanner) Scan() (Block, error)

Scan returns the next block from the reader.

type SyntaxError Uses

type SyntaxError struct {
    Message string
    Pos     Pos
}

func NewSyntaxError Uses

func NewSyntaxError(pos Pos, format string, args ...interface{}) *SyntaxError

func (*SyntaxError) Error Uses

func (e *SyntaxError) Error() string

type Template Uses

type Template struct {
    Path   string
    Blocks []Block
}

Template represents an entire Ego template. A template consists of zero or more blocks. Blocks can be either a TextBlock, a PrintBlock, a RawPrintBlock, or a CodeBlock.

func Parse Uses

func Parse(r io.Reader, path string) (*Template, error)

Parse parses an Ego template from a reader. The path specifies the path name used in the compiled template's pragmas.

func ParseFile Uses

func ParseFile(path string) (*Template, error)

ParseFile parses an Ego template from a file.

func (*Template) WriteTo Uses

func (t *Template) WriteTo(w io.Writer) (n int64, err error)

WriteTo writes the template to a writer.

type TextBlock Uses

type TextBlock struct {
    Pos     Pos
    Content string
}

TextBlock represents a UTF-8 encoded block of text that is written to the writer as-is.

Directories

PathSynopsis
cmd/ego

Package ego imports 13 packages (graph) and is imported by 1 packages. Updated 2019-01-21. Refresh now. Tools for package owners.