public function TwigExtension::drupalTitle in Twig Tweak 8
Same name and namespace in other branches
- 8.2 src/TwigExtension.php \Drupal\twig_tweak\TwigExtension::drupalTitle()
Returns a title for the current route.
Return value
array A render array to represent page title.
File
- src/
TwigExtension.php, line 363
Class
- TwigExtension
- Twig extension with some useful functions and filters.
Namespace
Drupal\twig_tweakCode
public function drupalTitle() {
$title = \Drupal::service('title_resolver')
->getTitle(\Drupal::request(), \Drupal::routeMatch()
->getRouteObject());
$build['#markup'] = render($title);
$build['#cache']['contexts'] = [
'url',
];
return $build;
}