Draft: Remove thunder processors; change raw field formatter; extend tests.
Merge request reports
Activity
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 } I've extended the tests for text & link paragraphs to cover various scenarios (field-formatter configurations) because:
-
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.
-
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-
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="<a href="http://example.com">Example site</a>"></pg-link> 295 EOF; @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- the first sub-test above produces