Class: SwitchProcessor

Inherits:
Object
  • Object
show all
Includes:
Thymeleaf::Processor
Defined in:
lib/thymeleaf/dialects/default/processors/switch.rb

Instance Method Summary collapse

Methods included from Thymeleaf::Processor

#evaluate_in_context, #load_template, #subprocess_node

Instance Method Details

#call(attribute: nil, context: nil, **_) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/thymeleaf/dialects/default/processors/switch.rb', line 4

def call(attribute:nil, context:nil, **_)
  condition = EvalExpression.parse(context, attribute.value)
  new_context = ContextHolder.new({}, context)
  new_context.set_private DefaultDialect::CONTEXT_SWITCH_VAR, condition

  attribute.unlink
  new_context
end

#has_subcontext?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/thymeleaf/dialects/default/processors/switch.rb', line 13

def has_subcontext?
  true
end