Class: Liquid::Case

### Home Classes Methods

### In Files

- lib/liquid/tags/case.rb

### Parent

Liquid::Block

### Methods

- ::new
- #render
- #unknown_tag

### 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::Case

### Constants

Syntax
WhenSyntax

### Public Class Methods

new(tag_name, markup, tokens) click to toggle source

    # File lib/liquid/tags/case.rb, line 6
    def initialize(tag_name, markup, tokens)
      @blocks = []

      if markup =~ Syntax
        @left = $1
      else
        raise SyntaxError.new("Syntax Error in tag 'case' - Valid syntax: case [condition]")
      end

      super
    end

### Public Instance Methods

render(context) click to toggle source

    # File lib/liquid/tags/case.rb, line 30
    def render(context)
      context.stack do
        execute_else_block = true

        output = ''
        @blocks.each do |block|
          if block.else?
            return render_all(block.attachment, context) if execute_else_block
          elsif block.evaluate(context)
            execute_else_block = false
            output << render_all(block.attachment, context)
          end
        end
        output
      end
    end

unknown_tag(tag, markup, tokens) click to toggle source

    # File lib/liquid/tags/case.rb, line 18
    def unknown_tag(tag, markup, tokens)
      @nodelist = []
      case tag
      when 'when'
        record_when_condition(markup)
      when 'else'
        record_else_condition(markup)
      else
        super
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.