ferron_common/util/
default_html_page.rs

1/// Formats a page with the given contents, title, and CSS stylesheets.
2#[macro_export]
3macro_rules! format_page {
4  ($contents:expr, $title:expr, $css:expr) => {{
5    let css = $css
6      .into_iter()
7      .map(|css| format!("<style>{}</style>", css))
8      .collect::<Vec<_>>()
9      .join("\n");
10    format!(
11      "<!doctype html>
12       <html lang=\"en\">
13           <head>
14               <meta charset=\"UTF-8\" />
15               <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />
16               <title>{}</title>
17               {}
18           </head>
19           <body>
20               {}
21           </body>
22       </html>
23",
24      $crate::util::anti_xss($title),
25      css,
26      $contents
27    )
28  }};
29}