Tweak twig dot notation not working correctly for push-url

Created on 2 November 2024, 12 days ago

Problem/Motivation

When using the tweak twig method of this module like this everything works fine

<span {{ htmx.get(drupal_url('node/1')).swap('outerHTML').trigger('click').target("article").boost('true') }}>Click me</span>

However adding push-url like this breaks the functionality with error:
<span {{ htmx.get(drupal_url('/node/1')).swap('outerHTML').trigger('click').target("#main-layout").boost('true').push-url('true') }}>Click me</span>

Symfony\Component\Routing\Exception\RouteNotFoundException: Route "true" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 208 of core/lib/Drupal/Core/Routing/RouteProvider.php).

I don't know if this is specific to the push-url or other HTMX attributes are affected by this.

πŸ› Bug report
Status

Active

Version

1.3

Component

Drupal Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @pierostz
  • First commit to issue fork.
  • πŸ‡ΊπŸ‡ΈUnited States fathershawn New York

    fathershawn β†’ changed the visibility of the branch 3485198-tweak-twig-dot to hidden.

  • πŸ‡ΊπŸ‡ΈUnited States fathershawn New York

    I'll do some testing. I would have expected a type exception with the given Twig expression. The function signature for that method is:

      public function pushUrl(bool|Url $value) {}
    

    I'm not clear why Twig is interpreting your string as a Url object.

  • πŸ‡ΊπŸ‡ΈUnited States fathershawn New York

    I'm still not sure what Twig was calling, but there is a syntax error in your code. The proper syntax for the method to generate a push url attribute is

    .pushUrl(true) or .pushUrl(someUrlObject)

Production build 0.71.5 2024