templ icon indicating copy to clipboard operation
templ copied to clipboard

Spread under attribute

Open iamajoe opened this issue 11 months ago • 7 comments

There is a case where you might want to have a spread on an attribute. Example:

<button class={ []string{"foo"}... }>Button</button>

This error comes in if i use this:

missing ',' in composite literal

If I generate like this instead:

<button class={ []string{"foo"}[0] }>Button</button>

Creates:

var templ_7745c5c3_Var2 = []any{[]string{"foo"}[0]}

Looking at the generation, it seems that supporting spread operator shouldn't be a problem. Some kind of parsing issue?!

iamajoe avatar Mar 12 '24 18:03 iamajoe