Documentation
¶
Index ¶
- Constants
- func UnionRefs(sets ...[]string) []string
- type BaseNode
- type Content
- type Esc
- type Expression
- type ExpressionsList
- type Function
- type HtmlAttribute
- type HtmlElement
- func (n *HtmlElement) AddChildren(children ...Node)
- func (n *HtmlElement) CollectAttributeVarRefs(reactive map[string]bool) []string
- func (n *HtmlElement) CollectVarRefs(reactive map[string]bool) []string
- func (n *HtmlElement) LastChild() Node
- func (n *HtmlElement) PopChild()
- func (n *HtmlElement) WriteGoCode(buf *gobuf.GoBuf)
- func (n *HtmlElement) WriteInnerGoCode(buf *gobuf.GoBuf)
- type HtmlRaw
- type Indexed
- type Loop
- type Node
- type Number
- type Operator
- type Parentheses
- type RawExpression
- type SsrAssets
- type SsrCondition
- type SsrConditionData
- type SsrContent
- type SsrForm
- type SsrInput
- type SsrJSON
- type SsrSelect
- type SsrTextarea
- type String
- type StructField
- type TernaryIf
- type Text
- type Variable
- type WithChildren
Constants ¶
const ( FormEncTypeMultipart = "multipart/form-data" FormEncUrlEncoded = "application/x-www-form-urlencoded" )
Form encodings.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Content ¶
Content is a run of text and values.
func (*Content) CollectVarRefs ¶
func (*Content) WriteGoCode ¶
type Esc ¶
type Esc uint8
Esc names the escaper generated code uses for an expression's value.
Escapers, one per HTML context.
type Expression ¶
type Expression struct {
BaseNode
Value Node
Esc Esc
// RCDATA is set for the text of <title> and <textarea>, which cannot hold a live value.
RCDATA bool
// Source is the trimmed text between {{ and }}.
Source string
// BindingKey is set for a live value; the value is then wrapped in <span data-ssr-bind="KEY">.
BindingKey string
}
Expression is a {{ }} value, written through the escaper Esc.
func (*Expression) CollectVarRefs ¶
func (n *Expression) CollectVarRefs(reactive map[string]bool) []string
func (*Expression) WriteGoCode ¶
func (n *Expression) WriteGoCode(buf *gobuf.GoBuf)
func (*Expression) WriteInnerGoCode ¶
func (n *Expression) WriteInnerGoCode(buf *gobuf.GoBuf)
WriteInnerGoCode writes the value without the live-value wrapper.
type ExpressionsList ¶
ExpressionsList is the arguments of a call.
func (*ExpressionsList) CollectVarRefs ¶
func (n *ExpressionsList) CollectVarRefs(reactive map[string]bool) []string
func (*ExpressionsList) WriteGoCode ¶
func (n *ExpressionsList) WriteGoCode(buf *gobuf.GoBuf)
type Function ¶
type Function struct {
BaseNode
Expr Node
Arguments *ExpressionsList
}
Function is a call.
func (*Function) CollectVarRefs ¶
func (*Function) WriteGoCode ¶
type HtmlAttribute ¶
HtmlAttribute is an attribute and its value as text and expressions.
type HtmlElement ¶
type HtmlElement struct {
BaseNode
TagName string
Attributes []HtmlAttribute
SelfClosed bool
Children []Node
// BlockKey is set when an attribute value is live; the element is then wrapped in
// <ssr-block data-ssr-bind="KEY"> and re-rendered whole.
BlockKey string
}
HtmlElement is an HTML element of the template.
func (*HtmlElement) AddChildren ¶
func (n *HtmlElement) AddChildren(children ...Node)
func (*HtmlElement) CollectAttributeVarRefs ¶
func (n *HtmlElement) CollectAttributeVarRefs(reactive map[string]bool) []string
CollectAttributeVarRefs returns the reactive variables the attribute values refer to, without the children.
func (*HtmlElement) CollectVarRefs ¶
func (n *HtmlElement) CollectVarRefs(reactive map[string]bool) []string
func (*HtmlElement) LastChild ¶
func (n *HtmlElement) LastChild() Node
func (*HtmlElement) PopChild ¶
func (n *HtmlElement) PopChild()
func (*HtmlElement) WriteGoCode ¶
func (n *HtmlElement) WriteGoCode(buf *gobuf.GoBuf)
func (*HtmlElement) WriteInnerGoCode ¶
func (n *HtmlElement) WriteInnerGoCode(buf *gobuf.GoBuf)
WriteInnerGoCode writes the element without the live-block wrapper.
type HtmlRaw ¶
HtmlRaw is markup written as it is, such as the doctype.
func (*HtmlRaw) WriteGoCode ¶
type Indexed ¶
Indexed is an index expression, a[i].
func (*Indexed) CollectVarRefs ¶
func (*Indexed) WriteGoCode ¶
type Loop ¶
type Loop struct {
BaseNode
Index string
Variable string
Array Node
Children []Node
// BlockKey is set when the list or the body is live; the whole loop output is then
// wrapped and re-rendered.
BlockKey string
}
Loop is an element with ssr:for.
func (*Loop) CollectVarRefs ¶
CollectVarRefs returns the reactive variables of the list and of the body.
func (*Loop) WriteGoCode ¶
func (*Loop) WriteInnerGoCode ¶
WriteInnerGoCode writes the loop without the live-block wrapper.
type Node ¶
type Node interface {
WriteGoCode(buf *gobuf.GoBuf)
// FilePos returns the //line directive of the node's template position.
FilePos() string
// CollectVarRefs returns the variables of reactive that the node's subtree refers to,
// never nil.
CollectVarRefs(reactive map[string]bool) []string
}
Node is a part of a parsed template that writes Go code.
type Number ¶
Number is a number literal. A negative one is written in parentheses, so it stays one operand after an operator, as in a-(-1).
func (*Number) WriteGoCode ¶
type Operator ¶
Operator is a unary or binary operator; Left is nil for "!".
func (*Operator) CollectVarRefs ¶
func (*Operator) WriteGoCode ¶
type Parentheses ¶
Parentheses is an expression in parentheses.
func (*Parentheses) CollectVarRefs ¶
func (n *Parentheses) CollectVarRefs(reactive map[string]bool) []string
func (*Parentheses) WriteGoCode ¶
func (n *Parentheses) WriteGoCode(buf *gobuf.GoBuf)
type RawExpression ¶
type RawExpression struct {
BaseNode
Value Node
// Source is the trimmed text between {{$ and }}.
Source string
// BindingKey is set for a live value; the value is then wrapped in <span data-ssr-bind="KEY">.
BindingKey string
}
RawExpression is a {{$ }} value. Its value must be a web.SafeHTML.
func (*RawExpression) CollectVarRefs ¶
func (n *RawExpression) CollectVarRefs(reactive map[string]bool) []string
func (*RawExpression) WriteGoCode ¶
func (n *RawExpression) WriteGoCode(buf *gobuf.GoBuf)
func (*RawExpression) WriteInnerGoCode ¶
func (n *RawExpression) WriteInnerGoCode(buf *gobuf.GoBuf)
WriteInnerGoCode writes the value without the live-value wrapper.
type SsrAssets ¶
type SsrAssets struct {
BaseNode
}
SsrAssets is <ssr:assets/>, where the page's script and style tags are written.
func (*SsrAssets) WriteGoCode ¶
type SsrCondition ¶
type SsrCondition struct {
BaseNode
Conditions []SsrConditionData
ElseBody Node
// BlockKey is set when a condition or a branch is live; the output is then wrapped in
// <ssr-block data-ssr-bind="KEY"> and re-rendered whole.
BlockKey string
}
SsrCondition is a chain of elements with ssr:if, ssr:else-if and ssr:else.
func (*SsrCondition) CollectVarRefs ¶
func (n *SsrCondition) CollectVarRefs(reactive map[string]bool) []string
func (*SsrCondition) WriteGoCode ¶
func (n *SsrCondition) WriteGoCode(buf *gobuf.GoBuf)
func (*SsrCondition) WriteInnerGoCode ¶
func (n *SsrCondition) WriteInnerGoCode(buf *gobuf.GoBuf)
WriteInnerGoCode writes the branches without the live-block wrapper.
type SsrConditionData ¶
SsrConditionData is one ssr:if or ssr:else-if branch.
type SsrContent ¶
SsrContent is <ssr:content/>, where the child page is written.
func (*SsrContent) CollectVarRefs ¶
func (n *SsrContent) CollectVarRefs(_ map[string]bool) []string
func (*SsrContent) WriteGoCode ¶
func (n *SsrContent) WriteGoCode(buf *gobuf.GoBuf)
type SsrForm ¶
type SsrForm struct {
BaseNode
Name string
DPCtxFieldName string
EncType string
Attributes []HtmlAttribute
Children []Node
}
SsrForm is an <ssr:form>. It posts to its own page with the form ID and the CSRF token in hidden fields.
func (*SsrForm) AddChildren ¶
func (*SsrForm) CollectVarRefs ¶
CollectVarRefs returns [] — form fields are not reactive.
func (*SsrForm) WriteGoCode ¶
type SsrInput ¶
type SsrInput struct {
BaseNode
Name string
FormFieldName string
Type string
// Value is the fixed value of a radio or checkbox input; GoValue is the same value as a
// Go literal of the field's gotype.
Value string
GoValue string
Multiple bool
Attributes []HtmlAttribute
}
SsrInput is an <ssr:input> form field.
func (*SsrInput) CollectVarRefs ¶
CollectVarRefs returns [] — form fields are not reactive.
func (*SsrInput) WriteGoCode ¶
type SsrJSON ¶
SsrJSON renders a value as JSON in a <script type="application/json"> element with id Name, so page scripts can read it without inline code.
func (*SsrJSON) CollectVarRefs ¶
func (*SsrJSON) WriteGoCode ¶
type SsrSelect ¶
type SsrSelect struct {
BaseNode
Name string
GoType string
FormFieldName string
Attributes []HtmlAttribute
Multiple bool
}
SsrSelect is an <ssr:select> form field; its options are set by the page's code.
func (*SsrSelect) CollectVarRefs ¶
CollectVarRefs returns [] — form fields are not reactive.
func (*SsrSelect) WriteGoCode ¶
type SsrTextarea ¶
type SsrTextarea struct {
BaseNode
Name string
FormFieldName string
Attributes []HtmlAttribute
}
SsrTextarea is an <ssr:textarea> form field.
func (*SsrTextarea) CollectVarRefs ¶
func (n *SsrTextarea) CollectVarRefs(_ map[string]bool) []string
CollectVarRefs returns [] — form fields are not reactive.
func (*SsrTextarea) WriteGoCode ¶
func (n *SsrTextarea) WriteGoCode(buf *gobuf.GoBuf)
type String ¶
String is a string literal. Text is the literal as Go source.
func (*String) WriteGoCode ¶
type StructField ¶
StructField is a selector, a.B.
func (*StructField) CollectVarRefs ¶
func (n *StructField) CollectVarRefs(reactive map[string]bool) []string
CollectVarRefs returns the variables of the expression the field is read from.
func (*StructField) WriteGoCode ¶
func (n *StructField) WriteGoCode(buf *gobuf.GoBuf)
type TernaryIf ¶
TernaryIf is "cond ? a : b".
func (*TernaryIf) CollectVarRefs ¶
func (*TernaryIf) WriteGoCode ¶
type Variable ¶
Variable is a name.
func (*Variable) CollectVarRefs ¶
func (*Variable) WriteGoCode ¶
type WithChildren ¶
WithChildren is a node that holds child nodes.