Documentation
¶
Index ¶
- Variables
- func GenerateHTML(w io.Writer, t *Template, values ...bindings.BindArg) error
- type AttributeNode
- type Case
- type CompileOptions
- type Condition
- type Content
- type ElementNode
- type IndentStyle
- type MultiNode
- type Node
- type NodeOption
- type RawNode
- type SubsectionNode
- type SwitchNode
- type Template
- type TextNode
- type Value
Constants ¶
This section is empty.
Variables ¶
var ( Compact = CompileOptions{ Indent: " ", Compact: true, } Tidy = CompileOptions{ Indent: " ", Compact: false, } Debug = CompileOptions{ Indent: " ", Compact: false, SeparateStaticChunks: true, } )
Functions ¶
Types ¶
type AttributeNode ¶
type AttributeNode struct { Name string Value Value RequiredTrust safe.TrustLevel }
func Attribute ¶
func Attribute(name string, value Value) *AttributeNode
func DataAttribute ¶
func DataAttribute(name string, value Value, trust safe.TrustLevel) *AttributeNode
func (*AttributeNode) Apply ¶
func (a *AttributeNode) Apply(n Node) error
Apply will insert the attribute into the node, which must be ElementNode.
type CompileOptions ¶
type CompileOptions struct { Indent string Compact bool SeparateStaticChunks bool TextWidth int RootDepth int }
func (*CompileOptions) String ¶
func (opts *CompileOptions) String() string
type Content ¶
func Indent ¶
func Indent(is IndentStyle) Content
func SelfClosing ¶
func SelfClosing() Content
func XMLElement ¶
func XMLElement() Content
XMLElement marks the element as non-HTML and overrides any HTML-derived defaults based on the element name.
type ElementNode ¶
type ElementNode struct { Name string Attributes []AttributeNode Contents []Node IndentStyle IndentStyle SelfClosing bool XMLStyleSelfClosing bool }
ElementNode represents an HTML element, like <p>.
func Element ¶
func Element(name string, contents ...Content) *ElementNode
func (*ElementNode) Apply ¶
func (e *ElementNode) Apply(n Node) error
type MultiNode ¶
type MultiNode struct {
Contents []Node
}
MultiNode concatenates several other nodes.
type NodeOption ¶
func (NodeOption) Apply ¶
func (f NodeOption) Apply(n Node) error
type RawNode ¶
type RawNode struct {
HTML Value
}
RawNode inserts a fully trusted string directly into the page.
type SubsectionNode ¶
SubsectionNode represents a self-contained part of the page, which can be repeated in the output, each time with different bindings. (For example, comments under an article might each be a subsection.)
Subsections can contain other subsections.
func (*SubsectionNode) Apply ¶
func (ns *SubsectionNode) Apply(n Node) error
type SwitchNode ¶
func (*SwitchNode) Apply ¶
func (sn *SwitchNode) Apply(n Node) error
type Template ¶
func MustCompile ¶
func MustCompile(n Node, m *bindings.Map, opts *CompileOptions) *Template
func (*Template) GenerateHTML ¶
type Value ¶
type Value interface {
Check(required safe.TrustLevel) bool
}
Value is a placeholder for a string value. The two types of values used in this package are binding.Var and safe.Value. The difference between the two is that Vars can be bound to a specific Value at a later time, while Strings are interpolated when we compile the template.
Value provides a way to check that the var or safe string conform to a minimal level of trust.