Class: Liquid2::MultiEqualBlock

Inherits:
Node
  • Object
show all
Defined in:
lib/liquid2/nodes/tags/case.rb

Overview

A Liquid block guarded by any one of multiple expressions.

Instance Attribute Summary

Attributes inherited from Node

#blank, #token

Instance Method Summary collapse

Methods inherited from Node

#block_scope, #partial_scope, #render_with_disabled_tag_check, #template_scope

Constructor Details

#initialize(token, left, conditions, block) ⇒ MultiEqualBlock

Returns a new instance of MultiEqualBlock.

Parameters:



90
91
92
93
94
95
96
# File 'lib/liquid2/nodes/tags/case.rb', line 90

def initialize(token, left, conditions, block)
  super(token)
  @left = left
  @conditions = conditions
  @block = block
  @blank = block.blank
end

Instance Method Details

#children(_static_context, include_partials: true) ⇒ Object



108
# File 'lib/liquid2/nodes/tags/case.rb', line 108

def children(_static_context, include_partials: true) = [@block]

#expressionsObject



109
# File 'lib/liquid2/nodes/tags/case.rb', line 109

def expressions = @conditions

#render(context, buffer) ⇒ Object



98
99
100
101
102
103
104
105
106
# File 'lib/liquid2/nodes/tags/case.rb', line 98

def render(context, buffer)
  left = context.evaluate(@left)
  if @conditions.map { |right| Liquid2.eq?(left, context.evaluate(right)) }.any?
    @block.render(context, buffer)
    true
  else
    false
  end
end