Skip to main content

rumtk_web_render_html

Function rumtk_web_render_html 

Source
pub fn rumtk_web_render_html<T: RUMWebTemplate>(
    template: T,
    url: RUMWebRedirect,
) -> HTMLResult
Expand description

Render the given component template into an HTML Body response or a URL Redirect response. If you provide the RUMWebRedirect in the url parameter configured for redirection, then we return the redirection as the response. Otherwise, we render the HTML and save it in the response.

ยงExample

use rumtk_web::{HTMLBody, RUMString, RUMWebRedirect, RUMWebResponse};
use rumtk_web::RUMWebTemplate;
use rumtk_web::rumtk_web_render_html;

#[derive(RUMWebTemplate)]
#[template(
    source = "<div></div>",
    ext = "html"
)]
struct Div { }

let result = rumtk_web_render_html(Div{}, RUMWebRedirect::None).unwrap();
let expected = RUMWebResponse::into_get_response("<div></div>");

assert_eq!(result, expected, "Test Div template rendered improperly!");