The https://templ.guide/syntax-and-usage/attributes/#json-attributes documentation states to create a function, but
|
// JSONString returns a JSON encoded string of v. |
|
func JSONString(v any) (string, error) { |
|
b, err := json.Marshal(v) |
|
if err != nil { |
|
return "", err |
|
} |
|
return string(b), nil |
|
} |
was designed for this purpose.
Need to update the docs.
The https://templ.guide/syntax-and-usage/attributes/#json-attributes documentation states to create a function, but
templ/jsonstring.go
Lines 7 to 14 in 04abee5
Need to update the docs.