Skip to content

Instantly share code, notes, and snippets.

@gregmercer
Created January 15, 2019 23:24
Show Gist options
  • Save gregmercer/4bf559910627fbf2ba51c4c54e9dc274 to your computer and use it in GitHub Desktop.
Save gregmercer/4bf559910627fbf2ba51c4c54e9dc274 to your computer and use it in GitHub Desktop.
D8 - Twig Templates Attach Library
Twig Templates
Attach Library
...
lightning-8/modules/custom/basic/css
animate.css
...
lightning-8/modules/custom/basic/basic.libraries.yml
basic-hero-style:
css:
theme:
css/animate.css: {}
...
lightning-8/modules/custom/basic/templates/basic-hero-list.html.twig
{{ attach_library('basic/basic-hero-style') }}
<h4>{{ title }}</h4>
<ol>
{% for item in items %}
<li class="animated {{ random(['bounce', 'flash', 'rubberBand', 'shake', 'jello', 'tada', 'bounceIn', 'rollIn']) }}">{{ item.name }}</li>
{% endfor %}
</ol>
<strong>This is coming from our custom twig file.</strong>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment