Skip to content

docs: fix suggestion to create your own JSON attribute function when not required #1435

Description

@a-h

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

// 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions