Skip to main content

rumtk_web/components/form/
form_element.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.
5 * Copyright (C) 2025  Nick Stephenson
6 * Copyright (C) 2025  Ethan Dixon
7 * Copyright (C) 2025  MedicalMasses L.L.C.
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 */
23use crate::components::form::props::InputProps;
24use crate::utils::types::HTMLResult;
25use crate::{rumtk_web_render_html, RUMWebTemplate};
26use askama::Template;
27
28#[derive(RUMWebTemplate, Debug, Clone)]
29#[template(
30    source = "
31        <{{element}} {{props.to_rumstring()|safe}} class='{{css_class}}'>{{data}}</{{element}}>
32    ",
33    ext = "html"
34)]
35pub struct FormElement<'a> {
36    element: &'a str,
37    data: &'a str,
38    props: InputProps<'a>,
39    css_class: &'a str,
40}
41
42pub fn form_element(element: &str, data: &str, props: InputProps, css_class: &str) -> HTMLResult {
43    rumtk_web_render_html!(FormElement {
44        element,
45        data,
46        props,
47        css_class
48    })
49}