utkarshkukreti / markup.rs

A blazing fast, type-safe template engine for Rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using `Render` trait for attribute values makes it easy to generate invalid HTML

utkarshkukreti opened this issue · comments

(Posting this here since I don't have time to fix this right now.)

Attribute values are currently rendered using the same Render trait that full templates use, which makes it easy to generate invalid markup:

markup::define! {
    A { #a {} }
    B { div[a = A {}] {} }
}

fn main() {
    println!("{}", B {});
}

=>

<div a="<div id="a"></div>"></div>

I think there should be a separate trait (that probably inherits markup::Render) for things that are allowed to be in attribute values and it should only be implemented by simple values like numbers, strings, booleans, and options that wrap them, and not templates defined by markup::define! or markup::new!.