Module moto::runtime

source ·

Functions§

  • dope doping is the process of identifying and replacing interpolatable variables in a string with their current values (from ctx) variables are identified by the following pattern: [:variable_name] or [:variable_name=default_value] or [:variable_name(arg1, arg2, …)] for example: “Hello, [:name]!” will be replaced with “Hello, John!” if ctx contains a variable named “name” with value “John” and “Hello, [:name=John]!” will be replaced with “Hello, John!” if ctx does not contain a variable named “name” and “Hello, [:name(John, Doe)]!” will be replaced with “Hello, how are you john the son of Doe?” if ctx has a function named “name” that takes two arguments and returns “how are you [0] the son of [1]?” and “Hello, [:name(John)]!” will be replaced with “Hello, John!” if ctx has a function named “name” that takes one argument and returns “Hello, [0]!”
  • find_interpolatable find the next interpolatable variable or function in the code identified by the following pattern: [:variable_name] or [:variable_name=default_value] or [:variable_name(arg1, arg2, …)] for example: “Hello, [:name]!” has [:name] as an interpolatable variable starting at index 7 and ending at index 13
  • get_function_value get the value of a function from the context if the function is not found in the context, return an empty string if the function is found in the context, call the function with the arguments and return the result
  • get_variable_value get the value of a variable from the context if the variable is not found in the context, return the default value