- Issue created by @neclimdul
- 🇺🇸United States neclimdul Houston, TX
As a workaround, you _can_ use the internal: prefix. For example
link('text', 'internal:#anchor')
. We should still address this though because this wouldn't be obvious to your average developer. Or experienced developer since I needed to have catch point it out and I think he had to dig through Url.php to find it 🤣 - Merge request !7007Improve DX of twig link function in twig templates. → (Open) created by neclimdul
- 🇺🇸United States neclimdul Houston, TX
Realized my concerns about optimizing this for existing conditions is probably not a big deal. Core is passing urls and that's probably the common use case. fromUserInput is probably the expected behavior the rest of the time.
That said, we can avoid cloning is we just created the object so I've included that in the merge.
Needs tests but the existing twig extension test needs a lot of scaffolding for each test so I will come back to it.
- Status changed to Needs review
11 months ago 5:01pm 12 March 2024 - 🇺🇸United States neclimdul Houston, TX
Needs test but approach could use some review.
- Status changed to Needs work
11 months ago 1:46pm 13 March 2024 - 🇺🇸United States smustgrave
The problem makes sense.
Was hoping we had a method that could check for userInput before calling it. To get around the try/catch block but didn't find anything.
Think it's probably a good enough approach to add a few test cases for.
Could you post the link to the slack thread in case others want to chime in there too.
Thanks!
- 🇺🇸United States neclimdul Houston, TX
Yeah, using try/catch as a conditional doesn't feel great. I considered moving the regex to a constant we could use but that felt weird to so open to suggestions.
https://drupal.slack.com/archives/C1BMUQ9U6/p1709912605839939