Add filter documentation in User Guide
This commit is contained in:
parent
d0ef795161
commit
9dfcfe2c45
|
@ -0,0 +1,37 @@
|
|||
# Filters
|
||||
|
||||
Filters are used to format the rendered contents.
|
||||
|
||||
Example:
|
||||
|
||||
```ejs
|
||||
message: <%= "foo\nbar" | dbg %>
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```html
|
||||
message: "foo\nbar"
|
||||
```
|
||||
|
||||
!!! Note
|
||||
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 doen't implement `Render` trait.
|
||||
|
||||
|
||||
## Syntax
|
||||
|
||||
- Apply filter and HTML escaping
|
||||
|
||||
```ejs
|
||||
<%= expression | filter %>
|
||||
```
|
||||
|
||||
- Apply filter only
|
||||
|
||||
```ejs
|
||||
<%- expression | filter %>
|
||||
```
|
||||
|
||||
## Built-In Filters
|
||||
|
||||
Built-In filters can be found in [`sailfish::runtime::filter`](https://docs.rs/sailfish/latest/sailfish/runtime/filter/index.html) module.
|
|
@ -32,6 +32,15 @@
|
|||
|
||||
Unlike EJS, you cannot omit the file extension.
|
||||
|
||||
## Helpers
|
||||
## Filters
|
||||
|
||||
(Work in progress)
|
||||
```ejs
|
||||
<%= message | upper %>
|
||||
```
|
||||
|
||||
```ejs
|
||||
{
|
||||
"id": <%= id %>
|
||||
"comment": <%- comment | dbg %>
|
||||
}
|
||||
```
|
||||
|
|
|
@ -50,3 +50,4 @@ nav:
|
|||
- 'Overview': 'syntax/overview.md'
|
||||
- 'Tags': 'syntax/tags.md'
|
||||
- 'Includes': 'syntax/includes.md'
|
||||
- 'Filters': 'syntax/filters.md'
|
||||
|
|
Loading…
Reference in New Issue