Module: Antlers::Variables
- Extended by:
- Queries
- Defined in:
- lib/modules/variables.rb
Instance Method Summary collapse
-
#evaluate(name:, current_binding:) ⇒ Object
Evaluation limited to the following for security and to prevent a templating language becoming a programming language.
- #fallback(value) ⇒ Object
Methods included from Queries
user_defined_string?, wrapped_in?
Instance Method Details
#evaluate(name:, current_binding:) ⇒ Object
Evaluation limited to the following for security and to prevent a templating language becoming a programming language.
- An instance variable
- A method call/local variable
- A method chain
- A static string
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/modules/variables.rb', line 14 def evaluate(name:, current_binding:) return name.to_s unless current_binding name, *chain = name.split('.') result = method_var(name:, current_binding:) return method_chain(result:, chain:) if chain.count > 0 return result if result nil rescue StandardError nil end |
#fallback(value) ⇒ Object
28 29 30 31 32 |
# File 'lib/modules/variables.rb', line 28 def fallback(value) return value[1..-2] if Queries.user_defined_string?(value) value end |