Pix*_*l0a 6 variables plugins liquid jekyll
我正在尝试研究如何将Jekyll变量传递给液体标签插件.我试过这样做:
{% liquidtag {{ variable }} %}
Run Code Online (Sandbox Code Playgroud)
但是变量没有实现,标签只是接收带有大括号的变量名: {{ variable }}
当我使用时,它也没有实现:{% liquidtag {% variable %} %}
- {%
在变量包含在字符串之前,变量%}
与第一个{%
液体标签匹配之后- 最后一次关闭%}
get被忽略.即,这传递:
{% variable
我想要的是将变量的实际值传递给标记.
这是标签:
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
Run Code Online (Sandbox Code Playgroud)
以下是我目前引用标记的方式:
{% for tag in site.categories %}
<div class="grid grid-pad">
<a><h2>{% CatAbs {{ tag[0] }} %} »</h2></a>
...
Run Code Online (Sandbox Code Playgroud)