Class: Liquid::Unless
Overview
Unless is a conditional just like ‘if’ but works on the inverse logic.
{% unless x < 0 %} x is greater than zero {% end %}
Constant Summary
Constants inherited from If
If::ExpressionsAndOperators, If::Syntax, If::SyntaxHelp
Constants inherited from Block
Block::ContentOfVariable, Block::FullToken, Block::IsTag, Block::IsVariable
Instance Attribute Summary
Attributes inherited from Tag
Instance Method Summary collapse
Methods inherited from If
Methods inherited from Block
#block_delimiter, #block_name, #create_variable, #end_tag, #parse, #unknown_tag
Methods inherited from Tag
Constructor Details
This class inherits a constructor from Liquid::If
Instance Method Details
#render(context) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/liquid/tags/unless.rb', line 10 def render(context) context.stack do # First condition is interpreted backwards ( if not ) block = @blocks.first unless block.evaluate(context) return render_all(block., context) end # After the first condition unless works just like if @blocks[1..-1].each do |block| if block.evaluate(context) return render_all(block., context) end end '' end end |