v1/vendor/chi-teck/drupal-code-generator/templates/hook/page_attachments.twig

13 lines
413 B
Twig

/**
* Implements hook_page_attachments().
*/
function {{ machine_name }}_page_attachments(array &$attachments) {
// Unconditionally attach an asset to the page.
$attachments['#attached']['library'][] = 'core/drupalSettings';
// Conditionally attach an asset to the page.
if (!\Drupal::currentUser()->hasPermission('may pet kittens')) {
$attachments['#attached']['library'][] = 'core/jquery';
}
}