Hello,
I’m trying to create a YouTube embedder using include
as described in Adding YouTube Embed Video Plugin.
This is the youtube-embedder.html
I craeted:
{% if include.class %}
<iframe class="{{ include.class }}" width="{{ include.width }}" height="{{ include.height }}" src="https://www.youtube.com/embed/{{ include.id }}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
{% else %}
<iframe width="{{ include.width }}" height="{{ include.height }}" src="https://www.youtube.com/embed/{{ include.id }}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
{% endif %}
Basically I want to enter the class if it is defined in the include
and nothing if it is not.
This is how I use it:
{% include youtube-embed.html id=tbUB7NWAtHw width=960 height=540 class="center-iframe" %}
Yet it doesn’t work.
What is wrong with the Control Flow I created?