Skip to content

Commit

Permalink
refactor: document structure of templ file by demonstrating interface…
Browse files Browse the repository at this point in the history
… implementation
  • Loading branch information
a-h committed Mar 15, 2024
1 parent ee4d1dd commit 358286c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.611
0.2.615
41 changes: 41 additions & 0 deletions parser/v2/structure.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package parser

// TemplateFileNodes are the top level nodes of a templ file.
var (
// css name() { ... }
_ TemplateFileNode = CSSTemplate{}
// templ name() { ... }
_ TemplateFileNode = HTMLTemplate{}
// script name() { ... }
_ TemplateFileNode = ScriptTemplate{}
// Go code within a templ file.
_ TemplateFileNode = TemplateFileGoExpression{}
)

// Nodes are all the nodes you can find in a `templ` component.
var (
_ Node = Text{}
_ Node = Element{}
_ Node = RawElement{}
_ Node = GoComment{}
_ Node = HTMLComment{}
_ Node = CallTemplateExpression{}
_ Node = TemplElementExpression{}
_ Node = ChildrenExpression{}
_ Node = IfExpression{}
_ Node = SwitchExpression{}
_ Node = ForExpression{}
_ Node = StringExpression{}
_ Node = Whitespace{}
_ Node = DocType{}
)

// Element nodes can have the following attributes.
var (
_ Attribute = BoolConstantAttribute{}
_ Attribute = ConstantAttribute{}
_ Attribute = BoolExpressionAttribute{}
_ Attribute = ExpressionAttribute{}
_ Attribute = SpreadAttributes{}
_ Attribute = ConditionalAttribute{}
)

0 comments on commit 358286c

Please sign in to comment.