Class: RemoveProcessor

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

Constant Summary collapse

REMOVE_ALL =
'all'
REMOVE_BODY =
'body'
REMOVE_TAG =
'tag'
REMOVE_ALL_BUT_FIRST =
'all-but-first'
REMOVE_NONE =
'none'

Instance Method Summary collapse

Methods included from Thymeleaf::Processor

#evaluate_in_context, #load_template, #subprocess_node

Instance Method Details

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



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/thymeleaf/dialects/default/processors/remove.rb', line 13

def call(node:nil, attribute:nil, context:nil, **_)
  attribute.unlink
  
  expr = EvalExpression.parse(context, attribute.value)
  
  method = case expr
             when REMOVE_ALL
               :remove_all
             when REMOVE_BODY
               :remove_body
             when REMOVE_TAG
               :remove_tag
             when REMOVE_ALL_BUT_FIRST
               :remove_allbutfirst
             when REMOVE_NONE
               :remove_none
             else
               if booleanize expr
                 :remove_all
               else
                 :remove_none
               end
             end
  
  send(method, node, context)
end