Ruby/Jekyll Plugin - How to render liquid variables inside plugin

I am creating a Jekyll plugin that executes an shell script with some (liquid or not) arguments.

I am having problems with it extrating the value of some liquid variables.
For example, if I use this plugin this way:

{% shellcmd image-responsive "{{ include.asset }}" %}

it is not rendering the {{ include.asset }} part. I need help, especially with this part.

The plugin, so far, is like this:

module Jekyll
  class ShellCommand < Liquid::Tag

    def initialize(tag_name, text, tokens)
      super
      @text = text
    end

    def render_variable(context)
      Liquid::Template.parse(@text).render(context)
    end

    def render(context)
      text = render_variable(@text)
      `#{text}`.strip
    end
  end
end

Liquid::Template.register_tag('shellcmd', Jekyll::ShellCommand)

How it should be?

To separate issues, if you use

'dummy value' %}

as the last argument does it work?

Then try {{ page.title }} %} or some other known variable.

Then try "{{ page.title }}" %} with quotes. I don’t know which will work.

Make sure that you are calling your custom filter plugin from inside an includes file and that you are indeed passing through the value.

You could leave out your plugin and just do a line which does this and see if the value shows up.

Asset {{ include.asset }}

I don’t know what tokens is for but perhaps you should store both text and tokens and log them so you can check what your plugin receives.

Run jekyll server --trace for verbose logging.

I’d suggest looking at other plugins which handle multiple arguments and see how they do it and then how they are called.

You can also try a quickstart plugin example and call it with your arguments within the context of an includes file and see that that works, in case you are missing something in your plugin