default
Allows you to specify a fallback in case a value doesn’t exist. default
will show its value if the left side is falsy or empty (string
or Array
).
In this example, product_price
is not defined, so the default value is used.
product_price
is defined, so the default value is not used.
product_price
is empty, so the default value is used.
Allowing false
To allow variables to return false
instead of the default value, you can use the allow_false
parameter.
json
Convert values to string via JSON.stringify()
, for debug purpose.
parse_json
Convert a string value to a valid JSON object. If the value is not a valid JSON, the returned value will be nil
.
Space
An additionalspace
parameter can be specified to format the JSON.
jsonify
See json.
inspect
Similar with json
, but inspect
allows cyclic structure. For the scope below:
Formatting
An additionalspace
argument can be specified for the indent width.