Rust

view

Module

Server-side views: templates with escaped params, filters, nesting and HTML minification.

A template is a Template function that writes the output; a view without one renders its file's content as is.

Contents

use utopia_http::View;
Rust
pub struct View

A view: a template path or function, its params and filters, and an optional parent view.

Also implements Debug.
use utopia_http::minify_html;
Rust
pub fn minify_html(html: &str) -> String

Minifies HTML: drops tabs and line breaks right after > and right before <, collapses runs of whitespace to one character, and keeps <textarea> and <pre> blocks intact.

Rust
pub type Filter = Arc<dyn Fn(&str) -> String + Send + Sync>

A filter: a string transformation registered by name.

Rust
pub type Template = Arc<dyn Fn(&View, &mut String) -> Result<()> + Send + Sync>

A template: renders a view into out.

Rust
pub const FILTER_ESCAPE: &str = "escape"

The name of the filter that HTML-escapes a value (every character with an HTML entity, quotes included).

Rust
pub const FILTER_NL2P: &str = "nl2p"

The name of the filter that wraps blank-line separated blocks in <p> and turns the remaining line breaks into <br />.