Skip to main content

rumtk_web_trim_rendered_html

Function rumtk_web_trim_rendered_html 

Source
pub fn rumtk_web_trim_rendered_html(html: String) -> String
Expand description

This function trims excess newlines and whitespacing outside tag block (e.g. <div></div>). The idea is to cleanup the rendered template which picks up extra characters due to the way string literals work in proc macros.

This is not meant to be used as a sanitization function!

This function consumes the input string!!!!!

ยงExample

use rumtk_web::rumtk_web_trim_rendered_html;
use rumtk_web::testdata::{TRIMMED_HTML_RENDER, UNTRIMMED_HTML_RENDER};

let expected = String::from(TRIMMED_HTML_RENDER);
let input = String::from(UNTRIMMED_HTML_RENDER);
let filtered = rumtk_web_trim_rendered_html(input);

assert_eq!(filtered, expected, "Template render trim failed!");