Skip to content
Snippets Groups Projects

Draft: Remove thunder processors; change raw field formatter; extend tests.

2 unresolved threads

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
194 'formatter' => 'field:string',
195 'is_slot' => FALSE,
196 'weight' => 0,
197 ])
201 198 ->setComponent('field_text', [
202 199 'name' => 'default',
203 'formatter' => 'auto',
200 'formatter' => 'field:text_default',
204 201 'is_slot' => TRUE,
202 'weight' => 1,
205 203 ])
206 204 ->save();
205 $custom_element = $ce_generator->generate($paragraph, 'full');
206 $markup = $this->renderCustomElement($custom_element);
207 $this->assertMarkupEquals($expected_markup, $markup);
208 }
  • Author Developer

    I've extended the tests for text & link paragraphs to cover various scenarios (field-formatter configurations) because:

    1. Tests aren't only tests, they also serve as sort-of documentation. I sure can't hold all these details in my head / will refer back to it to see differences - and I'm guessing that other devs who are going to dive into these configurations, will also find them.

    2. Call me slow (I sure think I am)... but I needed to carefully test auto vs raw vs various formatters (and get un-confused about v2 compatibility) before I had some Fingerspitzengefühl AND THEN was sure enough about what fixes to RawCeFieldFormatter are (un)needed.

    ( 3) by coincidence, I'm now seeing some possible Vue3 output bug below? )

    About the RawCeFieldFormatter changes: I plan to add

    • a config option to force using only the first value of a multivalue field (like you already mentioned also)
    • Only for single field values (or above option being enabled), just like DefaultFieldItemProcessor:
      • non-configurable: add the field's 'main property value' as a slot/attribute (unlike DefaultFieldItemProcessor, is_slot is cnofigurable)
      • non-configurable: add all other properties as attributes.

    This should be easy and hopefully quick. ParagraphLinkProcessor will then still not be perfectly replaced, because the href attribute will be named "uri" instead of "href" - which feels kind-of significant. But before I do anything about attribute renaming, I'll ask.

    Then - onto the entityreference fields.

    Edited by Roderik Muit
  • Please register or sign in to reply
  • 280 '<pg-link type="link" view-mode="full"><field-link title="Example site" slot="link">http://example.com</field-link></pg-link>';
    281 $custom_element = $ce_generator->generate($paragraph, 'full');
    282 $markup = $this->renderCustomElement($custom_element);
    283 $this->assertMarkupEquals($expected_markup, $markup);
    284
    285 // Field formatters output a HTML string, which will be output inside
    286 // a slot (div) or property (obviously HTML-encoded).
    287 $ce_display->setComponent('field_link', [
    288 'name' => 'link',
    289 'formatter' => 'field:link',
    290 'is_slot' => FALSE,
    291 ])
    292 ->save();
    293 $expected_markup = <<<EOF
    294 <pg-link type="link" view-mode="full" link="&lt;a href=&quot;http://example.com&quot;&gt;Example site&lt;/a&gt;"></pg-link>
    295 EOF;
    • Author Developer

      @fago: this (and one more below) should be :link="..., for Vue3 markup, right?

      I know nothing, but it feels strange to me that

      • the first sub-test above produces :link="...,
      • the two sub-tests where 'is_slot=TRUE' also produce different markup
      • but these two don't.

      I'm not checking the code for producing Vue3-style at the moment, but I made a note-to-self to do this.

      (Oh yeah - all expected_markup has been moved from CustomElementsRenderMarkupVue3Test::doTest*Paragraph() into these parent functions, because there can be multiple assertions in one method. Also, this happens to make things easier to compare.)

      Edited by Roderik Muit
    • Above comment is bogus: I slowly realized that vue3 style uses a ':' for all 'array' values. That is the difference.

    • Please register or sign in to reply
  • Author Developer

    Still draft - does nothing at the moment, just test additions (and changes that produce the same test results after removing some processors).

    This means that the link paragraphs still produce wrong output because that was already the case.

  • Closing; all conversions have been done in child issues. (I've copied the one comment change that I wanted to keep, into elsewhere.)

  • Please register or sign in to reply
    Loading