- Issue created by @fathershawn
- πΊπΈUnited States fathershawn New York
Missed bringing over the Twig function
The Needs Review Queue Bot β tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide β to find step-by-step guides for working with issues.
- πΊπΈUnited States fathershawn New York
Applied a suggestion and will refactoring some improvements inspired by @larowan review. A maintainer should add him to the credits.
- πΊπΈUnited States fathershawn New York
All tests green.
There are two open questions:
- π«π·France nod_ Lille
I don't understand why we need the single quote. If you add a JSON::encode(), to the process assets MR it just works.
$build['replace'] = [ '#type' => 'html_tag', '#tag' => 'button', '#attributes' => [ 'type' => 'button', 'name' => 'replace', 'data-hx-get' => $url->toString(), 'data-hx-select' => 'div.ajax-content', 'data-hx-target' => '[data-drupal-htmx-target]', // add this part 'data-hx-vals' => Json::encode(['test' => 'ok']), ], '#value' => 'Click this', '#attached' => [ 'library' => [ 'core/drupal.htmx', ], ], ];
It doesn't matter that the source html doesn't look pretty. Once it's in the JS it's the correct value.
- πΊπΈUnited States fathershawn New York
That's a great question! I didn't think it would but I didn't try. I'll repeat the experiment with an attribute value selector and remove the complexity. Simpler is better!!
- πΊπΈUnited States fathershawn New York
Confirmed! I can now remove a trait and a class - thank you @nod_ :)
I altered the render arrays in the test module to
$build['replace'] = [ '#type' => 'html_tag', '#tag' => 'button', '#attributes' => [ 'type' => 'button', 'name' => 'replace', 'data-hx-get' => $url->toString(), 'data-hx-select' => 'div.ajax-content', 'data-hx-target' => 'div[data-drupal-htmx-target="insert-here"]', ], '#value' => 'Click this', '#attached' => [ 'library' => [ 'core/drupal.htmx', ], ], ]; $build['content'] = [ '#type' => 'container', '#attributes' => [ 'data-drupal-htmx-target' => 'insert-here', 'class' => ['htmx-test-container'], ],
Which produces
data-hx-target="div[data-drupal-htmx-target="insert-here"]"
through the standard string attribute. HTMX worked as expected. - πΊπΈUnited States fathershawn New York
All threads resolved - all tests passing :)
- πΊπΈUnited States fathershawn New York
We agreed in Slack to pause on this builder while we work on π Refactor BigPipe to use HTMX Active using attributes that are "hand-rolled."