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

**URL:** <https://talk.jekyllrb.com/t/ruby-jekyll-plugin-how-to-render-liquid-variables-inside-plugin/3947>\
**Category:** Help\
**Created:** [February 20, 2020, 4:00pm UTC](https://talk.jekyllrb.com/t/ruby-jekyll-plugin-how-to-render-liquid-variables-inside-plugin/3947 "2020-02-20T16:00:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![danisantos](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@danisantos](https://talk.jekyllrb.com/u/danisantos)\
**Post date:** [February 20, 2020, 4:00pm UTC](https://talk.jekyllrb.com/t/ruby-jekyll-plugin-how-to-render-liquid-variables-inside-plugin/3947/1 "2020-02-20T16:00:20Z")

</div>

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:

```auto
{% 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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![MichaelCurrin](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/michaelcurrin/32/2340_2.png) [@MichaelCurrin](https://talk.jekyllrb.com/u/MichaelCurrin)\
**Post date:** [March 29, 2020, 9:11pm UTC](https://talk.jekyllrb.com/t/ruby-jekyll-plugin-how-to-render-liquid-variables-inside-plugin/3947/2 "2020-03-29T21:11:55Z")

</div>

To separate issues, if you use

```auto
'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.

```auto
Asset {{ include.asset }}

```

---

<div class="post-metadata">

**Author:** ![MichaelCurrin](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/michaelcurrin/32/2340_2.png) [@MichaelCurrin](https://talk.jekyllrb.com/u/MichaelCurrin)\
**Post date:** [March 29, 2020, 9:17pm UTC](https://talk.jekyllrb.com/t/ruby-jekyll-plugin-how-to-render-liquid-variables-inside-plugin/3947/3 "2020-03-29T21:17:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MichaelCurrin](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/michaelcurrin/32/2340_2.png) [@MichaelCurrin](https://talk.jekyllrb.com/u/MichaelCurrin)\
**Post date:** [March 29, 2020, 9:20pm UTC](https://talk.jekyllrb.com/t/ruby-jekyll-plugin-how-to-render-liquid-variables-inside-plugin/3947/4 "2020-03-29T21:20:35Z")

</div>

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

> **[Tags](https://jekyllrb.com/docs/plugins/tags/)**
>
> If you’d like to include custom liquid tags in your site, you can do so by hooking into the tagging system. Built-in examples added by Jekyll include the highlight and include tags. Below is an example of a custom liquid tag that will output the time...
