Skip to main content

float

Function float 

Source
pub fn float(
    state: &State<'_, '_>,
    value: &Value,
    default: Option<Value>,
    kwargs: Kwargs,
) -> Result<Value, Error>
Expand description

Converts a value into a float.

If the value cannot be converted and a default is given, the default is returned instead of an error. none converts to the default or 0.0.

{{ "42.5"|float == 42.5 }} -> true
{{ "n/a"|float(default=0.0) }} -> 0.0