【发布时间】:2012-08-13 06:05:36
【问题描述】:
考虑以下已解析的模板及其 root.nodelist 的循环:
text = '{% if true %}{{ "poland" | capitalize }}{% else %}{{ "portugal" | capitalize}}{% endif %}'
template = Liquid::Template.parse(text)
template.root.nodelist.each { |node| p node }
只打印:
Portugal
(而不是波兰)
如何从模板中列出所有节点(包括 Liquid 变量、标签等)?尤其是 if/else 逻辑中的那些?
【问题讨论】: