Replace component() function by include()

Created on 26 November 2024, 23 days ago

Problem/Motivation

Since UI Patterns 2.0.0-beta5 (Thursday 28 November) and 📌 [2.0.0-alpha3] Replace component() function by native Twig mechanisms? Active , we are promoting the use of Twig include function: https://twig.symfony.com/doc/3.x/functions/include.html

In UI Patterns 2.0.0-rc1, we will remove our custom component() function.

Proposed resolution

Replace all usages of:

{{ component('my-theme:my_component', {
    my_slot_1: content,
    my_slot_2: "Lorem ipsum",
   }, {
    my_prop_1: foo,
    my_prop_2: true,
  }) }}

By:

{{ include('my-theme:my_component', {
  my_prop_1: foo,
  my_prop_2: true,
  my_slot_1: content,
  my_slot_2: "Lorem ipsum",
}, with_context = false) }}

2 main differences:

  • props and slots are in a single parameter
  • with_context = false is necessary to avoid unexpected variables in the component template
📌 Task
Status

Active

Version

4.0

Component

Code

Created by

🇫🇷France pdureau Paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024