Module: Antlers::SlotLexeme

Extended by:
SlotLexeme
Includes:
Lexeme
Included in:
SlotLexeme
Defined in:
lib/lexemes/slot_lexeme.rb

Constant Summary collapse

KEYWORDS =
['slot:', ':slot'].freeze

Instance Method Summary collapse

Instance Method Details

#lexeme(name:, props:) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/lexemes/slot_lexeme.rb', line 16

def lexeme(name:, props:, **)
  if name.end_with?(':')
    slot_def = { slot_def: name.delete_suffix(':') }
    slot_def[:props] = props(props) unless props.empty?
    return slot_def
  end

  { slot_end: name.delete_prefix(':') }
end

#match?(name:) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/lexemes/slot_lexeme.rb', line 12

def match?(name:, **)
  name && (name.start_with?(':') || name.end_with?(':'))
end