public TwigExtension::attachLibrary($library)
Attaches an asset library to the template, and hence to the response.
Allows Twig templates to attach asset libraries using
{{ attach_library('extension/library_name') }}
string $library: An asset library.
public function attachLibrary($library) { // Use Renderer::render() on a temporary render array to get additional // bubbleable metadata on the render stack. $template_attached = ['#attached' => ['library' => [$library]]]; $this->renderer->render($template_attached); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Template!TwigExtension.php/function/TwigExtension::attachLibrary/8.1.x