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 {% endunless %}
Constant Summary
Constants inherited from If
If::BOOLEAN_OPERATORS, If::ExpressionsAndOperators, If::Syntax
Constants inherited from Block
Block::ContentOfVariable, Block::FullToken, Block::TAGSTART, Block::VARSTART
Instance Attribute Summary
Attributes inherited from Tag
#line_number, #nodelist, #options, #warnings
Instance Method Summary collapse
Methods inherited from If
#initialize, #nodelist, #unknown_tag
Methods inherited from Block
#blank?, #block_delimiter, #block_name, #create_variable, #parse, #render_token_with_profiling, #unknown_tag, #warnings
Methods inherited from Tag
#blank?, #initialize, #name, parse, #parse, #raw
Methods included from ParserSwitching
Constructor Details
This class inherits a constructor from Liquid::If
Instance Method Details
#render(context) ⇒ Object
9 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 9 def render(context) context.stack do # First condition is interpreted backwards ( if not ) first_block = @blocks.first unless first_block.evaluate(context) return render_all(first_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 ''.freeze end end |