2020-07-17 05:06:06 -04:00
# Filters
Filters are used to format the rendered contents.
Example:
2021-01-03 04:00:29 -05:00
=== "Template"
2020-07-17 05:06:06 -04:00
2021-01-03 04:00:29 -05:00
``` rhtml
2024-03-15 18:05:31 -04:00
message: < %\html "foo\nbar" | dbg %>
2021-01-03 04:00:29 -05:00
```
2020-07-17 05:06:06 -04:00
2021-01-03 04:00:29 -05:00
=== "Result"
``` html
message: " foo\nbar"
```
2020-07-17 05:06:06 -04:00
!!! Note
2024-03-15 18:05:31 -04:00
Since `dbg` filter accepts `<T: std::fmt::Debug>` types, that type isn't required to implement [`Render` ](https://docs.rs/sailfish/latest/sailfish/runtime/trait.Render.html ) trait. That means you can pass the type which doesn't implement `Render` trait.
2020-07-17 05:06:06 -04:00
## Syntax
2024-03-15 18:05:31 -04:00
- Apply filter and HTML escaping
2020-07-17 05:06:06 -04:00
2024-03-15 18:05:31 -04:00
```rhtml
< %\html expression | filter %>
2020-07-17 05:06:06 -04:00
```
2024-03-15 18:05:31 -04:00
- Apply filter only
2020-07-17 05:06:06 -04:00
2024-03-15 18:05:31 -04:00
```rhtml
2020-07-17 05:06:06 -04:00
< %- expression | filter %>
```
## Built-In Filters
2024-03-15 18:05:31 -04:00
Built-In filters can be found in [`sailfish::filter` ](https://docs.rs/sailfish/latest/sailfish/runtime/filter/index.html ) module.