Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Filters

Filters modify expressions that precede them:

oxip
{{ "foo" | upper }}

FOO

Behind the scenes, filters are functions in the filters_for_oxiplate module located in the current scope that are passed the result of the expression as the first argument. Additional arguments can be passed to the filter directly:

oxip
{{ "hello world" | replace("hello", "goodbye") }}

goodbye world

Built-in filters

Oxiplate has a number of filters declared in the filters module.

To use these on their own without any additional filters, import ::oxiplate::filters as filters_for_oxiplate. Or use ::oxiplate::prelude::* which does the same, along with importing the Oxiplate macro and Render trait.

Alternatively, a custom set of filters can be built once:

all built-in filters plus additional
extern crate oxiplate;

mod filters_for_oxiplate {
    use ::oxiplate::filters::*;

    // Additional filters here
}
subset of built-in filters plus additional
extern crate oxiplate;

mod filters_for_oxiplate {
    use ::oxiplate::filters::{lower, upper};

    // Additional filters here
}

And then used throughout the package:

rust
extern crate oxiplate;

mod filters_for_oxiplate {}

fn main() {
use ::oxiplate::{Oxiplate, Render};
use crate::filters_for_oxiplate;

// Template structs and functions to call `render()`
}

CowStr filters

CowStr is generated via the cow prefix.

FilterDescription
lowerConverts to lowercase
trimTrims leading and trailing whitespace
trim_endTrims trailing whitespace
trim_startTrims leading whitespace
upperConverts to uppercase

Option filters

FilterArgumentsDescription
defaultdefault_valueUnwraps Some value or uses default_value