Class: Liquid::Unless

### Home Classes Methods

### In Files

- lib/liquid/tags/unless.rb

### Parent

Liquid::If

### Methods

- #render

### Class/Module Index

Quicksearch

- Liquid
- Liquid::ArgumentError
- Liquid::Assign
- Liquid::BlankFileSystem
- Liquid::Block
- Liquid::Break
- Liquid::BreakInterrupt
- Liquid::Capture
- Liquid::Case
- Liquid::Comment
- Liquid::Context
- Liquid::ContextError
- Liquid::Continue
- Liquid::ContinueInterrupt
- Liquid::Cycle
- Liquid::Decrement
- Liquid::Document
- Liquid::Drop
- Liquid::ElseCondition
- Liquid::Error
- Liquid::FileSystemError
- Liquid::FilterNotFound
- Liquid::For
- Liquid::If
- Liquid::Ifchanged
- Liquid::Include
- Liquid::Increment
- Liquid::Interrupt
- Liquid::LocalFileSystem
- Liquid::MemoryError
- Liquid::Raw
- Liquid::StackLevelError
- Liquid::StandardError
- Liquid::StandardFilters
- Liquid::SyntaxError
- Liquid::TableRow
- Liquid::Tag
- Liquid::Template
- Liquid::Unless
- Liquid::Utils
- Liquid::Variable
- FalseClass
- LiquidView
- Module
- NilClass
- TrueClass

No matching classes.

# Liquid::Unless

Unless is a conditional just like 'if' but works on the inverse logic.

    {% unless x < 0 %} x is greater than zero {% end %}

### Public Instance Methods

render(context) click to toggle source

    # File lib/liquid/tags/unless.rb, line 10
    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.attachment, 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.attachment, context)
          end
        end

        ''
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.