-2

How can I call a JAVASCRIPT plugin in Twig template?
I try to use something like this code in my html.html.twig template, but it seems that this not work correctly:

<script>
  $(document).foundation();
</script>

Is there any difference between html and twig?

4

Do it properly in a file (the plugin initialisation), add the file via a library, then load the library in the template file using twig:

{{ attach_library('mytheme/mylibraryname') }}

See https://www.drupal.org/developing/api/8/assets

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.