0
module MyFilter
def all_caps(input)
input.upcase
end
end
Liquid::Template.register_filter(MyFilter)
template = Liquid::Template.parse(" {{ 'hi john' | all_caps }} ")
template.render
# => " HI JOHN "
template = Liquid::Template.parse(" {{ 'hi {{name}}' | all_caps }} ")
template.render('name' => 'john')
# => " ' | all_caps }} "
我该如何解决这个问题?官方文件中没有提及。如何在液体过滤器参数下访问变量?
注意:为简单起见,我使用了all_caps示例。我想实现一些复杂的事情。