- Issue created by @spryah
- Status changed to Postponed: needs info
over 1 year ago 5:09pm 23 August 2023 - 🇫🇷France pdureau Paris
Hi,
I am not able to test it right now, but I believe the current pattern() function already allow to inject a mix of fields ("slots") and settings ("props") in its second parameter :
new TwigFunction('pattern', [ $this, 'renderPattern', ]), ]; } public function renderPattern($id, array $fields = [], $variant = "") { return [ '#type' => 'pattern', '#id' => $id, '#fields' => $fields, '#variant' => $variant, ]; }
We don't need to use the specific #settings property because at the end the #fields and #settings are flattened and merged before being rendered with the template.
For example, in https://git.drupalcode.org/project/ui_suite_dsfr/-/blob/1.0.x/templates/...
pattern('modal', { modal_id: modal_id, title: modal_title, ... })
Where modal_id is a setting ("prop") and title is a field ("slot") : https://git.drupalcode.org/project/ui_suite_dsfr/-/blob/1.0.x/templates/...
What do you think about that?
- 🇫🇷France spryah
Hi @pdureau,
Thanks a lot for your detailed answer. I carried out a few tests to replace the occurrences ofpattern_with_settings
withpattern
and all proved conclusive. I suppose that simplifies a lot of things. - Status changed to Closed: works as designed
over 1 year ago 3:43pm 24 August 2023