Inheriting components
Sometimes, we will want to build a component that can be injected into views. To do this, we are going to have to load both the CSS and HTML, and then insert them into the correct parts of the HTML.
To do this, we must create a add_component
function that takes the name of the component, creates tags from the component name, and loads the HTML and CSS based on the component's name. We will define this function in the views/app/content_loader.rs
file:
pub fn add_component(component_tag: String, html_data: String) -> String { let css_tag: String = component_tag.to_uppercase() + &String::from("_CSS"); let html_tag...