Module: Antlers::VarLexeme

Extended by:
Queries, VarLexeme
Includes:
Lexeme
Included in:
VarLexeme
Defined in:
lib/lexemes/var_lexeme.rb

Constant Summary

Constants included from Lexeme

Lexeme::KEYWORDS

Instance Method Summary collapse

Methods included from Queries

user_defined_string?, wrapped_in?

Instance Method Details

#lexeme(segment:, raw:) ⇒ Object



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

def lexeme(segment:, raw:, **)
  # String is already interpolated or not depending on user input on the template layer, now we store it without those template quotes.
  segment = segment[1..-2] if Queries.user_defined_string?(segment)

  return { raw_var: segment } if raw

  { var: segment }
end

#match?Boolean

Variables are special and are matched by the lexer.

Returns:

  • (Boolean)


13
14
15
# File 'lib/lexemes/var_lexeme.rb', line 13

def match?(**)
  false
end