diff --git a/README.md b/README.md index d49437d6..ed99d2c2 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ Note: if you need support for Neovim 0.6.x please use the tag `compat/0.6`. - [x] `swift` - [x] `tcl` - [x] `teal` + - [x] `templ` - [x] `terraform` - [x] `toml` - [x] `tsx` diff --git a/queries/templ/context.scm b/queries/templ/context.scm new file mode 100644 index 00000000..ef4cf0ce --- /dev/null +++ b/queries/templ/context.scm @@ -0,0 +1,22 @@ +; inherits: go,html + +([ + (component_declaration) + (script_declaration) + (css_declaration) + (component_switch_statement) + (component_switch_expression_case) + (component_switch_default_case) +] @context) + +(component_if_statement + consequence: (component_block (_) @context.end) +) @context + +(component_for_statement + body: (component_block (_) @context.end) +) @context + +(component_import + body: (component_block (_) @context.end) +) @context diff --git a/test/test.templ b/test/test.templ new file mode 100644 index 00000000..60836a5e --- /dev/null +++ b/test/test.templ @@ -0,0 +1,161 @@ +package main + +import ( + "fmt" + + + + + + "time" +) + +templ headerTemplate(name string) { +
+ switch name { + + + + + + + + + + + + + case "Alice", "Bob": +

{ name }

+ + + + + + + + + + + + + default: + + + + + + + + + + + + + +

{ "Unknown" }

+ } + + +
+} + +templ posts(posts []Post) { + @layout("Posts") { + + + + + + + + @postsTemplate(posts) + if len(posts) > 0 { +
{ "Not empty" }
+ + + + + + + + + + + + } else { + + + + + + + + + + +
{ "Empty" }
+ } + } +} + +templ postsTemplate(posts []Post) { +
+ for _, p := range posts { + +
+
{ p.Name }
+
{ p.Author }
+ + + + + + + + + + + + + + + + +
+ } +
+} + +script withParameters(a string, b string, c int) { + + + + + + + + + console.log(a, b, c); +} + +css red() { + + + + + + + + + + + + + background-color: #ff0000; + font-family: "Iosevka"; +}