I have a Webform form (formerly the YAMLForm module) on which I need to show the title of the form. The template I am using is based on page.html.twig (because of twig debug suggestion) page--webform--stories-submission.html.twig.
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].
Just to make sure I'm doing it right, I put all of the following smack into the middle of my template:
{{ drupal_token('current-date:long') }}
{{ drupal_token('site:name') }}
{{ drupal_token('webform:title') }}
{{ drupal_token('webform:id') }}
I get this in return:
Wednesday, January 18, 2017 - 09:00 ECLKC [webform:title] [webform:id]
The first two prove that Twig Tweak is a wonderful thing, and the second two prove that I'm still not doing it right.
Can anyone recommend a next step for me?
If I can't get Tweak working, I guess I might need to preprocess myself a variable? Kint says that my title is right there as a page variable:
'page' => array(25)
~
'#title' => string(29) "Submit your Head Start Story!"
In that case, I think I would need to follow this advice: How do I add a variable for a Twig template in my preprocess function?
To sum up:
- Can I get Twig Tweak to show my title for me?
- If not, should I use that advice about adding a variable to my template preprocess?