Problem/Motivation

Since UI Patterns 2.0.0-beta5 (Thursday 28 November) and #3449653: [2.0.0-beta5] Replace component() function by native include() function, 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
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pdureau created an issue. See original summary.

niharika.s’s picture

Assigned: Unassigned » niharika.s
g4mbini’s picture

Title: Replace component() function by include() » [4.0.0-alpha7] Replace component() function by include()
g4mbini’s picture

Assigned: niharika.s » g4mbini
Issue tags: +UI Suite Initiative
g4mbini’s picture

  • g4mbini committed b5b47c72 on 4.0.x
    Issue #3489965 by pdureau, g4mbini: [4.0.0-alpha7] Replace component()...
g4mbini’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.