Skip to content

Commit

Permalink
Configure *can't* be used on arrays! :(
Browse files Browse the repository at this point in the history
  • Loading branch information
AugustMiller committed Nov 19, 2024
1 parent af701aa commit 6c009ba
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions docs/5.x/reference/twig/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,18 +270,7 @@ Passes through the behavior of the `Craft::configure()` method inherited from [`
}).all() %}
```

It can also be used instead of the [`merge`](https://twig.symfony.com/doc/3.x/filters/merge.html) filter:

```twig
{% set myObject = { one: 'Original' } %}
{# With `merge`: #}
{% set myObject = myObject | merge({ one: 'Overridden', two: 'New' }) %}
{# With `configure`: #}
{% do configure(myObject, { one: 'Overridden', two: 'New' }) %}
```

It could technically even be used to set a model or element’s attributes, even though that’s not a great idea since templates generally present content rather than modify it:
`configure()` _can_ be used to set a model or element’s attributes—but we don’t generally recommend this, as templates are intended to present content rather than modify it:

```twig
{% do configure(entry, { title: 'New Title' }) %}
Expand Down

0 comments on commit 6c009ba

Please sign in to comment.