Skip to content

Commit

Permalink
docs: return error from code component (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
wdscxsj authored Sep 30, 2023
1 parent efd3312 commit 90b7c8e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/docs/04-core-concepts/01-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ import (
)

func button(text string) templ.Component {
return templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) {
io.WriteString(w, "<button>"+text+"</button>")
return nil
return templ.ComponentFunc(func(ctx context.Context, w io.Writer) error {
_, err := io.WriteString(w, "<button>"+text+"</button>")
return err
})
}

Expand All @@ -54,6 +54,6 @@ func main() {
```

:::warning
This code is unsafe! In code-only components, you're responsible for escaping the HTML content yourself.
This code is unsafe! In code-only components, you're responsible for escaping the HTML content yourself, e.g. with the `templ.EscapeString` function.
:::

0 comments on commit 90b7c8e

Please sign in to comment.