According to the tokens listed in both in the form creation area and in admin/help/token, I have several tokens available including [webform:title], [webform:url], and [webform:id] to name a few.
When I use
{{ drupal_token('webform:title') }}
on my template, all that prints out on the page is [webform:title].
The cool folks over at Drupal Answers helped out by letting me know that "Currently, it looks like the Twig Tweak module's drupal_token Twig function does not support passing in the $data argument, which would contain the webform entity." They suggested I create an issue requesting this feature.
Thanks.
Comments
Comment #3
Chi CreditAttribution: Chi commentedGood catch. I just added support for the $data argument. You can find it in dev release. Note that to make use of it you should have an appropriate variable in your template which holds required context (Webform in your case).
For instance, node.html.twig template provides a special variable called node. So it's possible to extract tokens from it as follows:
{{ drupal_token('node:title', {node: node}) }}
Thanks for the report.
Comment #4
leraa CreditAttribution: leraa commentedI think I'm not supposed to waste everyone's time and space by saying thank you, but I'm going to do it anyway. Thank you for adding this feature and so quickly!