Documentation ¶
Index ¶
- func EscapeString(s string) string
- type Attribute
- type CallTemplateExpression
- type CaseExpression
- type Component
- type ComponentFunc
- type ConstantAttribute
- type Element
- type Expression
- type ExpressionAttribute
- type ForExpression
- type IfExpression
- type Import
- type Node
- type Package
- type ParseError
- type Position
- type Range
- type SourceExpressionTo
- type SourceMap
- func (sm *SourceMap) Add(src Expression, tgt Range) (updatedFrom Position)
- func (sm *SourceMap) SourcePositionFromTarget(line, col int) (src Position, mapping SourceExpressionTo, ok bool)
- func (sm *SourceMap) TargetPositionFromSource(line, col int) (tgt Position, mapping SourceExpressionTo, ok bool)
- type StringExpression
- type SwitchExpression
- type Template
- type TemplateFile
- type TemplateFileParser
- type Whitespace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EscapeString ¶
EscapeString escapes HTML text within templates.
Types ¶
type CallTemplateExpression ¶
type CallTemplateExpression struct { // Expression returns a template to execute. Expression Expression }
CallTemplateExpression can be used to create and render a template using data. {%! Other(p.First, p.Last) %} or it can be used to render a template parameter. {%! v %}
func (CallTemplateExpression) IsNode ¶
func (cte CallTemplateExpression) IsNode() bool
type CaseExpression ¶
type CaseExpression struct { Expression Expression Children []Node }
{% case "Something" %} ... {% endcase %}
type ComponentFunc ¶
ComponentFunc converts a function that matches the Component interface's Render method into a Component.
type ConstantAttribute ¶
href=""
func (ConstantAttribute) IsAttribute ¶
func (ca ConstantAttribute) IsAttribute() bool
func (ConstantAttribute) String ¶
func (ca ConstantAttribute) String() string
type Expression ¶
Expression containing Go code.
func NewExpression ¶
func NewExpression(value string, from, to Position) Expression
NewExpression creates a Go expression.
type ExpressionAttribute ¶
type ExpressionAttribute struct { Name string Expression Expression }
href={%= ... }
func (ExpressionAttribute) IsAttribute ¶
func (ea ExpressionAttribute) IsAttribute() bool
func (ExpressionAttribute) String ¶
func (ea ExpressionAttribute) String() string
type ForExpression ¶
type ForExpression struct { Expression Expression Children []Node }
{% for i, v := range p.Addresses %}
{% call Address(v) %}
{% endfor %}
func (ForExpression) IsNode ¶
func (fe ForExpression) IsNode() bool
type IfExpression ¶
type IfExpression struct { Expression Expression Then []Node Else []Node }
{% if p.Type == "test" && p.thing %} {% endif %}
func (IfExpression) IsNode ¶
func (n IfExpression) IsNode() bool
type Import ¶
type Import struct {
Expression Expression
}
{% import "strings" %} {% import strs "strings" %}
type ParseError ¶ added in v0.0.89
ParseError details where the error occurred in the file.
func (ParseError) Error ¶ added in v0.0.89
func (pe ParseError) Error() string
type Position ¶
Source mapping to map from the source code of the template to the in-memory representation.
func NewPositionFromInput ¶
NewPositionFromInput creates a position from a parse input.
func NewPositionFromValues ¶
NewPositionFromValues initialises a position.
type SourceExpressionTo ¶
type SourceExpressionTo struct { Source Expression Target Range }
SourceExpressionTo is a record of an expression, along with its start and end positions.
type SourceMap ¶
type SourceMap struct {
Items []SourceExpressionTo
}
func NewSourceMap ¶
func NewSourceMap() *SourceMap
NewSourceMap creates a new lookup to map templ source code to items in the parsed template.
func (*SourceMap) Add ¶
func (sm *SourceMap) Add(src Expression, tgt Range) (updatedFrom Position)
Add an item to the lookup.
func (*SourceMap) SourcePositionFromTarget ¶
func (sm *SourceMap) SourcePositionFromTarget(line, col int) (src Position, mapping SourceExpressionTo, ok bool)
SourcePositionFromTarget looks the source position using the target position.
func (*SourceMap) TargetPositionFromSource ¶
func (sm *SourceMap) TargetPositionFromSource(line, col int) (tgt Position, mapping SourceExpressionTo, ok bool)
TargetPositionFromSource looks up the target position using the source position.
type StringExpression ¶
type StringExpression struct {
Expression Expression
}
StringExpression is used within HTML elements. {%= ... %}
func (StringExpression) IsNode ¶
func (se StringExpression) IsNode() bool
type SwitchExpression ¶
type SwitchExpression struct { Expression Expression Cases []CaseExpression Default []Node }
{% switch p.Type %}
{% case "Something" %} {% endcase %}
{% endswitch %}
func (SwitchExpression) IsNode ¶
func (se SwitchExpression) IsNode() bool
type Template ¶
type Template struct { Name Expression Parameters Expression Children []Node }
Template definition. {% templ Name(p Parameter) %}
{% if ... %} <Element></Element>
{% endtempl %}
type TemplateFile ¶
func Parse ¶
func Parse(fileName string) (TemplateFile, error)
func ParseString ¶
func ParseString(template string) (TemplateFile, error)
type TemplateFileParser ¶
type TemplateFileParser struct { }
func NewTemplateFileParser ¶
func NewTemplateFileParser() TemplateFileParser
NewTemplateFileParser creates a new TemplateFileParser.
type Whitespace ¶
type Whitespace struct {
Value string
}
Whitespace.
func (Whitespace) IsNode ¶
func (ws Whitespace) IsNode() bool
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
counter
Module
|
|
counter-basic
Module
|
|
external-libraries
Module
|
|
integration-chi
Module
|
|
integration-echo
Module
|
|
integration-gin
Module
|
|
integration-go-echarts
Module
|
|
integration-gofiber
Module
|
|
integration-react
Module
|
|
internationalization
Module
|
|
static-generator
Module
|
|
typescript
Module
|
|
testdependents
module
|