Data Variables in Plugins

I would like you use a data variable in a plugin. From my understanding, it should be

 {% youtube {{ video.number }} %}

The plugin is working if I test it with a manual correct youtube id

I also tried

 {% youtube  video.number  %}
 {% youtube "{{ video.number }}" %}

what is the correct way?

Which Jekyll YouTube plugin are you using?

Why is this important? I am creating something new. The problem is not related to a specific youtube plugin. The Variable has the correct value but is not usable within a plugin.

When using the plugin with the id instead of the variable holding the id its working.

It’s important because not all Jekyll plugins are created equal. The one you are using may not support using a Liquid variable inside of a tag.

hm, it was my understanding that the build process would substitute the variable for the plugin and the plugin would never see the variable. The plugin has now idea about the context in which it was called.

In my case I am looping over a list from a data file

        {% for video in entry.video %}  
          {% youtube {{ video.number }} %}
        {% endfor %}

That works if the plugin allows for variables/front matter… and they don’t all do that. That is why it’s important that we know which Jekyll Youtube plugin you’re using.

For example this plugin does support support variables/front matter (at least from the what their documentation says).

Ok, then I have to rephrase my question. Is there any documentation how a plugin has to be implemented so that it allows to be started with variables?

They’re all different. It depends on the plugin and how it was developed as they may not follow the same conventions.

When in doubt check the plugin’s documentation as they should explain how to use it and if it accepts variables or just strings.

Jekyll’s documentation on writing a plugin has links to the various types of plugins (converters, tags, filters, etc.) and best practices to keep in mind.

ok, could we continue the discussion without general pointers to general pages that do not answer my questions? I understand that nobody wants to do the searching for somebody else.

I have read most of the jekyll documents about plugins, done googling for 10 pages but I still have not found advice /examples / snippets that describe how to write a plugin so that you can pass content to a plugin via a variable.

Using Dommel’s jekyll-youtube plugin Gem and following the doc for setup and use, the following page works as expected (tested code):

test.md:

---
video: "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
---

{% youtube page.video %}