But how do you know which template to clear from the cache? You'd either need to perform some kind of reverse mapping of partial includes to determine all templates including the partial, or maintain your own metadata. Neither sound very appealing.
Another solution is to make your partial includes happen at run-time.
class JustInTimeInclude < ::Liquid::Include
alias :super_parse :parse
def parse(tokens)
@tokens = tokens
end
def render(context)
super_parse(@tokens)
super
end
end
alias :super_parse :parse
def parse(tokens)
@tokens = tokens
end
def render(context)
super_parse(@tokens)
super
end
end
and replace the current include tag with your own:
Liquid::Template.register_tag('include', JustInTimeInclude)
No comments:
Post a Comment