【发布时间】:2015-09-24 14:19:41
【问题描述】:
我的 Jekyll 网站中有几个元素不能很好地用于摘录,尤其是在 RSS 提要中使用时。由于它们是由 Liquid 标签创建的(在自定义插件中实现),我认为它应该很容易做到。这样的事情看起来很谨慎:
module Jekyll
class MyTag < Liquid::Tag
def initialize(tag_name, text, tokens)
super
end
def render(context)
if <in excerpt>
""
else
"this should not be in an excerpt"
end
end
end
end
Liquid::Template.register_tag('mytag', Jekyll::MyTag)
不过,我不知道如何检查标签是否呈现为摘录。转储context.environments、context.scopes 和context.registers 的内容并没有发现任何有用的信息。
我该怎么做?
【问题讨论】:
标签: ruby jekyll liquid jekyll-extensions