Hi !

When using single directory components, I cannot render them in ui_examples. It seems thats props and slots get prefixed with # in ExampleSyntaxConverter, preventing them from being rendered properly.

Edit : here's a sample of the yaml for the rendered elements :

render:
  - type: html_tag
    tag: 'h1'
    value: 'Title'
  - type: component
    component: 'theme_name:button'
    props:
      type: primary
      title: ''
      tag: 
      text: 'Link title
      url: 'https://www.link-url.com'
      target: '_blank'

I found a workaround for this, by adding this piece of (untested) code :

# ExampleSyntaxConverter.php:59

protected function convertRenderArray(array $renderable): array {
    foreach ($renderable as $property => $value) {
      if (in_array($property, ['props', 'slots'])) {
        continue;
      }
// ...
  }
// ...
}

Have I missed something ? If not, I'll submit a MR with said changes.

Thanks,

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

jmaxant created an issue. See original summary.

jmaxant’s picture

Component: Documentation » Code
Issue summary: View changes
jmaxant’s picture

Issue summary: View changes
pdureau’s picture

Assigned: Unassigned » pdureau

It may be because of type: primary which is part of ::RENDER_KEYS

you are proposing to skip both slots and props but may be more complicated (and indirectly related to this Core issue: #3494634: Compatibility between SDC and the Form API)

I will do a little test

pdureau’s picture

Assigned: pdureau » grimreaper
Status: Active » Needs work

Hi Grimreaper,

This is the opportunity of reoganizing our logic: https://git.drupalcode.org/project/ui_examples/-/merge_requests/21/diffs

The MR is not tested and is a bit too verbose and clunky, I will finish the job, but it is a good base for discussion for us.

(Let's not forget this logic must be duplicated in UI Patterns 2, so let's keep it lean).

(Is it the opportunity of supporting #theme => table ?)

pdureau’s picture

Title: Support Single directory components » Support render arrays using render properties as render children

grimreaper made their first commit to this issue’s fork.

grimreaper’s picture

Version: 1.0.1 » 1.x-dev
Assigned: grimreaper » pdureau
Status: Needs work » Needs review
grimreaper’s picture

Issue tags: +ddd2025
grimreaper’s picture

MR updated regarding MR in UIP

pdureau’s picture

Assigned: pdureau » Unassigned
Status: Needs review » Fixed

  • pdureau committed fc10d3af on 1.x
    Issue #3505217 by grimreaper, pdureau, jmaxant: Support render arrays...

Status: Fixed » Closed (fixed)

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