Skip to main content

rumtk_web/components/html/
main.rs

1/*
2 * rumtk attempts to implement HL7 and medical protocols for interoperability in medicine.
3 * This toolkit aims to be reliable, simple, performant, and standards compliant.
4 * Copyright (C) 2025  Luis M. Santos, M.D. <lsantos@medicalmasses.com>
5 * Copyright (C) 2025  Ethan Dixon
6 * Copyright (C) 2025  MedicalMasses L.L.C. <contact@medicalmasses.com>
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20 */
21use crate::defaults::DEFAULT_NO_TEXT;
22use crate::{rumtk_web_collect_page, rumtk_web_get_param, rumtk_web_render_contents, ComponentResult, RUMWebTemplate, RUMWebTemplateSafe, SharedAppState, URLParams, URLPath};
23use rumtk_core::strings::RUMString;
24
25#[derive(RUMWebTemplate)]
26#[template(
27    source = "
28        <main class='' id='main-content'>
29             <div class='padding-bottom-200'>
30
31             </div>
32             {{contents|safe}}
33             <div class='padding-bottom-50'>
34
35           </div>
36        </main>
37    ",
38    ext = "html"
39)]
40pub struct Main {
41    contents: RUMString,
42}
43
44impl RUMWebTemplateSafe for Main {}
45
46pub fn main(path_components: URLPath, params: URLParams, state: SharedAppState) -> ComponentResult<Main> {
47    let page: RUMString =
48        rumtk_web_get_param!(path_components, 0, RUMString::from(DEFAULT_NO_TEXT));
49
50    //Let's render the main tag contents
51    let body_components = rumtk_web_collect_page!(page, state)?;
52    let contents = rumtk_web_render_contents(&body_components)?;
53
54    Ok(Main { contents: contents.to_string() })
55}