|
@@ -70,6 +70,8 @@ impl Renderer {
|
|
|
.or_insert_with(|| Rc::new(StringCache::from_template(template).unwrap()))
|
|
|
.clone();
|
|
|
|
|
|
+ let mut inner_html = None;
|
|
|
+
|
|
|
// We need to keep track of the dynamic styles so we can insert them into the right place
|
|
|
let mut accumulated_dynamic_styles = Vec::new();
|
|
|
|
|
@@ -77,7 +79,9 @@ impl Renderer {
|
|
|
match segment {
|
|
|
Segment::Attr(idx) => {
|
|
|
let attr = &template.dynamic_attrs[*idx];
|
|
|
- if attr.namespace == Some("style") {
|
|
|
+ if attr.name == "dangerous_inner_html" {
|
|
|
+ inner_html = Some(attr);
|
|
|
+ } else if attr.namespace == Some("style") {
|
|
|
accumulated_dynamic_styles.push(attr);
|
|
|
} else {
|
|
|
match attr.value {
|
|
@@ -165,6 +169,19 @@ impl Renderer {
|
|
|
accumulated_dynamic_styles.clear();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ Segment::InnerHtmlMarker => {
|
|
|
+ if let Some(inner_html) = inner_html.take() {
|
|
|
+ let inner_html = &inner_html.value;
|
|
|
+ match inner_html {
|
|
|
+ AttributeValue::Text(value) => write!(buf, "{}", value)?,
|
|
|
+ AttributeValue::Bool(value) => write!(buf, "{}", value)?,
|
|
|
+ AttributeValue::Float(f) => write!(buf, "{}", f)?,
|
|
|
+ AttributeValue::Int(i) => write!(buf, "{}", i)?,
|
|
|
+ _ => {}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -208,7 +225,9 @@ fn to_string_works() {
|
|
|
StyleMarker {
|
|
|
inside_style_tag: false,
|
|
|
},
|
|
|
- PreRendered(">Hello world 1 -->".into(),),
|
|
|
+ PreRendered(">".into()),
|
|
|
+ InnerHtmlMarker,
|
|
|
+ PreRendered("Hello world 1 -->".into(),),
|
|
|
Node(0,),
|
|
|
PreRendered(
|
|
|
"<-- Hello world 2<div>nest 1</div><div></div><div>nest 2</div>".into(),
|