Replace component() function by include()

Created on 26 November 2024, 5 months 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