rocket_dyn_templates::minijinja::filters

Function split

Source
pub fn split(
    s: Arc<str>,
    split: Option<Arc<str>>,
    maxsplits: Option<i64>,
) -> Value
Expand description

Split a string into its substrings, using split as the separator string.

If split is not provided or none the string is split at all whitespace characters and multiple spaces and empty strings will be removed from the result.

The maxsplits parameter defines the maximum number of splits (starting from the left). Note that this follows Python conventions rather than Rust ones so 1 means one split and two resulting items.

{{ "hello world"|split|list }}
    -> ["hello", "world"]

{{ "c,s,v"|split(",")|list }}
    -> ["c", "s", "v"]