Skip to content

Commit

Permalink
turbo_refreshes_with docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgrande committed Jan 12, 2024
1 parent efdebd6 commit e6b47a5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/source/template-tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

Generate `turbo-frame` and `turbo-stream` from Django template is now the **recommended** way since it is more clean and easy to understand.

## turbo_refreshes_with

This template tag generates HTML meta tags for Turbo Drive to control the refresh method and scroll behavior in Turbo 8.0+ ([currently in beta](https://github.com/hotwired/turbo/releases/tag/v8.0.0-beta1)).

### Parameters

- `method` (optional, default: `'replace'`): Specifies the refresh method. Must be one of `'replace'` or `'morph'`.
- `scroll` (optional, default: `'reset'`): Specifies the scroll behavior. Must be one of `'reset'` or `'preserve'`.

### Behavior

This tag creates HTML meta tags defining the Turbo Frames' refresh method and scroll behavior based on the provided parameters. If the provided parameters are not within the valid options, a `ValidationError` is raised.

### Example Usage

```django
{% load custom_tags %}
<!-- Generate Turbo Frames refresh meta tags -->
{% turbo_refreshes_with method='replace' scroll='reset' %}
```

## dom_id

`dom_id` is a helper method that returns a unique DOM ID based on the object's class name and ID
Expand Down

0 comments on commit e6b47a5

Please sign in to comment.