Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs for blade @cascade directive #1440

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions content/collections/docs/blade.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,30 @@ If you use a method, it will give you a query builder and allow you to chain cla
@endforeach
```

### Cascade Directive

When using blade components or rendering views loaded by non-Statamic routes/controllers the cascade data will be not avaliable by default. In these situations you can use the `@cascade` directive to populate the current scope with cascade data.

It works in exactly the same way as the `@props` directive used in blade components, with the ability to require certain values and provide default fallback values:

```blade
@cascade([
'site', // Will throw an exception if missing from the cascade
'my_global',
'page' => null, // Will use fallback if missing from the cascade
'live_preview' => false,
])

{{ $site->locale }}
{{ $page?->title }}
```

It is also possible to populate the current scope with all cascade data if needed:

```blade
@cascade
```

## Writing Pure Antlers in Blade 🆕

By using the `@antlers` and `@endantlers` Blade directive pair you can write pure Antlers in your Blade templates.
Expand Down