// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ // ┃ Copyright: (c) 2023, Mike 'PhiSyX' S. (https://github.com/PhiSyX) ┃ // ┃ SPDX-License-Identifier: MPL-2.0 ┃ // ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃ // ┃ ┃ // ┃ This Source Code Form is subject to the terms of the Mozilla Public ┃ // ┃ License, v. 2.0. If a copy of the MPL was not distributed with this ┃ // ┃ file, You can obtain one at https://mozilla.org/MPL/2.0/. ┃ // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ use lexa_framework::html; use lexa_framework::view::Node; // --------- // // Structure // // --------- // pub struct BaseHTMLLayout { title: String, body: Node, metadata: Vec, styles: Vec, scripts: Vec, } // -------------- // // Implémentation // -> Interface // -------------- // impl lexa_framework::view::ViewLayoutInterface for BaseHTMLLayout { type Metadata = Node; type Scripts = Node; type Styles = Node; type View = Node; fn new() -> Self where Self: Sized, { Self { title: Default::default(), body: Default::default(), metadata: Default::default(), styles: Default::default(), scripts: Default::default(), } } fn set_title(&mut self, title: impl ToString) { self.title = title.to_string(); } fn set_body(&mut self, body: Self::View) { self.body = body; } fn add_meta(&mut self, meta: Self::Metadata) { self.metadata.push(meta); } fn add_script(&mut self, script: Self::Scripts) { self.scripts.push(script); } fn add_style(&mut self, style: Self::Styles) { self.styles.push(style); } fn view(&self) -> Self::View { html!( BaseHTMLLayout: { &self.title } { unsafe for self.metadata } { unsafe for self.styles } { unsafe &self.body } { unsafe for self.scripts } ) } }