I’m trying to access data in site.data
from a custom Liquid tag that I’ve created. I’m not sure how to do it. I’ve copied below what I have tried to do, but I get the error:
Liquid Exception: undefined method `registers' for nil:NilClass @definition = @context.registers[:site].data.terminology["{@category}"]['definition'] ^^^^^^^^^^ in ...
module Jekyll
class Term < Liquid::Tag
def initialize(tag_name, input, tokens)
super
vars = input.split(" ")
@term = vars[0]
@category = vars[1]
end
def render(context)
@definition = @context.registers[:site].data.terminology["{@category}"]['definition']
"#{@definition}"
end
end
end
Liquid::Template.register_tag('term', Jekyll::Term)
I’m rather new to ruby so please excuse my inexperience.