1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use std::fmt::{Debug, Formatter};
use dyn_clone::DynClone;
use crate::node::{Node, NodeContainer};
use crate::{DefaultModifiers, Renderable};
#[derive(Debug, Clone)]
pub struct DynamicContent {
node: Node,
pub name: String,
}
impl DynamicContent {
pub fn new(name: &str) -> Self {
DynamicContent {
node: Default::default(),
name: name.to_string()
}
}
}
impl NodeContainer for DynamicContent {
fn get_node(&mut self) -> &mut Node {
&mut self.node
}
}
impl DefaultModifiers<DynamicContent> for DynamicContent {}
impl Renderable for DynamicContent {
fn render(&self) -> Node {
let mut dynamic_content = self.clone()
.add_class("dynamic-content")
.set_attr("data-dynamic-content-name", &self.name);
dynamic_content.node.clone()
}
}