Skip to content

Commit

Permalink
document functions
Browse files Browse the repository at this point in the history
  • Loading branch information
levkk committed Nov 8, 2024
1 parent 0f3e337 commit 498204b
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion docs/docs/views/templates/functions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ Inserts JavaScript code which will create and initialize a [Turbo Stream](../../
[^1]: [https://turbo.hotwired.dev/handbook/streams](https://turbo.hotwired.dev/handbook/streams)



### `render`

Renders a template directly inside the current template. Can be used for rendering [partials](../partials.md). `<%%` is a special template code tag which is an alias for `render`.
Expand All @@ -122,3 +121,23 @@ Renders a template directly inside the current template. Can be used for renderi
<%% "templates/profile.html" %>
</div>
```

### `csrf_token`

Renders an input field with a valid [CSRF](../../../security/CSRF.md) token.

```html
<form action="/login" method="post">
<%= csrf_token() %>
</form>
```


### `csrf_token_raw`

Renders a valid [CSRF](../../../security/CSRF.md) token as a raw HTML string. It can then be passed to JavaScript via a `data-` attribute or a global variable:

```html
<div data-csrf-token="<%= csrf_token_raw() %>"
</div>
```

0 comments on commit 498204b

Please sign in to comment.