I'm trying to work out how to pass a Jekyll variable to a liquid tag plugin. I tried doing this:
{% liquidtag {{ variable }} %}
But the variable does not get realised and the tag just receives the variable name with the curly brackets: {{ variable }}
It also does not get realised when I use: {% liquidtag {% variable %} %}
- the {%
before the variable gets included in the string and the %}
after the variable gets matched with the first {%
of the liquid tag - the last closing %}
get's ignored. I.e, this gets passed:
{% variable
What I want is for the actual value of the variable to be passed to the tag.
Here's the tag:
class CatAbs < Liquid::Tag
def initialize(tag_name, text, tokens)
super
@text = text
puts @text
end
def render(context)
return @text.split("-").at(1)
end
end
And here's how I'm currently referencing the tag:
{% for tag in site.categories %}
<div class="grid grid-pad">
<a><h2>{% CatAbs {{ tag[0] }} %} »</h2></a>
...
After a lot of searching, I finally found the answer. I don't know why it was so difficult for me to find before! Sorry for the duplicate question!
Here's the answer I found:
using Liquid variables inside of a liquid tag call
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With