jade: github.com/Joker/jade Index | Files | Directories

package jade

import "github.com/Joker/jade"

Jade.go - template engine. Package implements Jade-lang templates for generating Go html/template output.

Index

Package Files

config.go config_string.go jade_lex.go jade_node.go jade_parse.go lex.go node.go parse.go template.go

Variables

var TabSize = 4

func Config Uses

func Config(c Cfg)

func ConfigOtputPHP Uses

func ConfigOtputPHP()

func Parse Uses

func Parse(name string, text []byte) (string, error)

Parse parses the template definition string to construct a representation of the template for execution.

Trivial usage:

package main

import (
	"fmt"
	"github.com/Joker/jade"
)

func main() {
	tpl, err := jade.Parse("tpl_name", "doctype 5: html: body: p Hello world!")
	if err != nil {
		fmt.Printf("Parse error: %v", err)
		return
	}

	fmt.Printf( "Output:\n\n%s", tpl  )
}

Output:

<!DOCTYPE html><html><body><p>Hello world!</p></body></html>

func ParseFile Uses

func ParseFile(filename string) (string, error)

ParseFile parse the jade template file in given filename

type BlockNode Uses

type BlockNode struct {
    NodeType
    Pos

    Name string
    // contains filtered or unexported fields
}

func (*BlockNode) Copy Uses

func (t *BlockNode) Copy() Node

func (*BlockNode) String Uses

func (t *BlockNode) String() string

func (*BlockNode) WriteIn Uses

func (t *BlockNode) WriteIn(b io.Writer)

type Cfg Uses

type Cfg struct {
    GolangMode bool
    TagBgn     string
    TagEnd     string
    TagVoid    string
    TagArgEsc  string
    TagArgUne  string
    TagArgStr  string
    TagArgAdd  string
    TagArgBgn  string
    TagArgEnd  string

    CondIf     string
    CondUnless string
    CondCase   string
    CondWhile  string
    CondFor    string
    CondEnd    string
    CondForIf  string

    CodeForElse   string
    CodeLongcode  string
    CodeBuffered  string
    CodeUnescaped string
    CodeElse      string
    CodeElseIf    string
    CodeCaseWhen  string
    CodeCaseDef   string
    CodeMixBlock  string

    TextStr     string
    TextComment string

    MixinBgn         string
    MixinEnd         string
    MixinVarBgn      string
    MixinVar         string
    MixinVarRest     string
    MixinVarEnd      string
    MixinVarBlockBgn string
    MixinVarBlock    string
    MixinVarBlockEnd string
}

type CodeNode Uses

type CodeNode struct {
    NodeType
    Pos

    Code []byte // The text; may span newlines.
    // contains filtered or unexported fields
}

func (*CodeNode) Copy Uses

func (t *CodeNode) Copy() Node

func (*CodeNode) String Uses

func (t *CodeNode) String() string

func (*CodeNode) WriteIn Uses

func (t *CodeNode) WriteIn(b io.Writer)

type CondNode Uses

type CondNode struct {
    NodeType
    Pos

    Nodes []Node
    // contains filtered or unexported fields
}

func (*CondNode) Copy Uses

func (l *CondNode) Copy() Node

func (*CondNode) CopyCond Uses

func (l *CondNode) CopyCond() *CondNode

func (*CondNode) String Uses

func (l *CondNode) String() string

func (*CondNode) WriteIn Uses

func (l *CondNode) WriteIn(b io.Writer)

type DoctypeNode Uses

type DoctypeNode struct {
    NodeType
    Pos
    // contains filtered or unexported fields
}

func (*DoctypeNode) Copy Uses

func (d *DoctypeNode) Copy() Node

func (*DoctypeNode) String Uses

func (d *DoctypeNode) String() string

func (*DoctypeNode) WriteIn Uses

func (d *DoctypeNode) WriteIn(b io.Writer)

type ListNode Uses

type ListNode struct {
    NodeType
    Pos

    Nodes []Node // The element nodes in lexical order.
    // contains filtered or unexported fields
}

ListNode holds a sequence of nodes.

func (*ListNode) Copy Uses

func (l *ListNode) Copy() Node

func (*ListNode) CopyList Uses

func (l *ListNode) CopyList() *ListNode

func (*ListNode) String Uses

func (l *ListNode) String() string

func (*ListNode) WriteIn Uses

func (l *ListNode) WriteIn(b io.Writer)

type MixinNode Uses

type MixinNode struct {
    NodeType
    Pos

    Nodes     []Node
    AttrName  []string
    AttrCode  []string
    AttrRest  []string
    MixinName string
    // contains filtered or unexported fields
}

func (*MixinNode) Copy Uses

func (l *MixinNode) Copy() Node

func (*MixinNode) CopyMixin Uses

func (l *MixinNode) CopyMixin() *MixinNode

func (*MixinNode) String Uses

func (l *MixinNode) String() string

func (*MixinNode) WriteIn Uses

func (l *MixinNode) WriteIn(b io.Writer)

type Node Uses

type Node interface {
    Type() NodeType
    String() string
    WriteIn(io.Writer)
    // Copy does a deep copy of the Node and all its components.
    // To avoid type assertions, some XxxNodes also have specialized
    // CopyXxx methods that return *XxxNode.
    Copy() Node
    Position() Pos // byte position of start of node in full original input string
    // contains filtered or unexported methods
}

A Node is an element in the parse tree. The interface is trivial. The interface contains an unexported method so that only types local to this package can satisfy it.

type NodeType Uses

type NodeType int

NodeType identifies the type of a parse tree node.

const (
    NodeText NodeType = iota
    NodeList
    NodeTag
    NodeCode
    NodeCond
    NodeString
    NodeDoctype
    NodeMixin
    NodeBlock
)

func (NodeType) String Uses

func (i NodeType) String() string

func (NodeType) Type Uses

func (t NodeType) Type() NodeType

Type returns itself and provides an easy default implementation for embedding in a Node. Embedded in all non-trivial Nodes.

type Out Uses

type Out struct {
    Name, Args, Import string
}
var Go Out

type Pos Uses

type Pos int

Pos represents a byte position in the original input text from which this template was parsed.

func (Pos) Position Uses

func (p Pos) Position() Pos

type TagNode Uses

type TagNode struct {
    NodeType
    Pos

    Nodes    []Node
    AttrName []string
    AttrCode []string
    AttrUesc []bool
    TagName  string
    // contains filtered or unexported fields
}

func (*TagNode) Copy Uses

func (l *TagNode) Copy() Node

func (*TagNode) CopyTag Uses

func (l *TagNode) CopyTag() *TagNode

func (*TagNode) String Uses

func (l *TagNode) String() string

func (*TagNode) WriteIn Uses

func (l *TagNode) WriteIn(b io.Writer)

type TextNode Uses

type TextNode struct {
    NodeType
    Pos

    Text []byte // The text; may span newlines.
    // contains filtered or unexported fields
}

func (*TextNode) Copy Uses

func (t *TextNode) Copy() Node

func (*TextNode) String Uses

func (t *TextNode) String() string

func (*TextNode) WriteIn Uses

func (t *TextNode) WriteIn(b io.Writer)

type Tree Uses

type Tree struct {
    Name string    // name of the template represented by the tree.
    Root *ListNode // top-level root of the tree.
    // contains filtered or unexported fields
}

Tree is the representation of a single parsed template.

func New Uses

func New(name string) *Tree

New allocates a new parse tree with the given name.

func (*Tree) Copy Uses

func (t *Tree) Copy() *Tree

Copy returns a copy of the Tree. Any parsing state is discarded.

func (*Tree) Parse Uses

func (t *Tree) Parse(text []byte) (tree *Tree, err error)

func (*Tree) WriteIn Uses

func (t *Tree) WriteIn(b io.Writer)

Directories

PathSynopsis
exampleCode generated by "jade.go"; DO NOT EDIT.
example/v1.0
example/v1.0/actions
example/v1.0/jade_extends
example/v1.0/jade_include

Package jade imports 15 packages (graph) and is imported by 35 packages. Updated 2019-06-17. Refresh now. Tools for package owners.