Open mmstick opened 5 years ago
Never thought someone would use this for generating non HTML/XML data! I added auto escaping like most HTML/XML templating languages do -- to prevent accidental XSS attacks. You could shorten markup::raw
to r
like this:
use markup::raw as r;
...
"Type=" {r(kind.type_str())} "\n"
Just 3 extra characters now. Maybe that is good enough?
I tried to use this for code generation via build.rs and was disappoint of escaping. I'd suggest you to add new macro, called define_raw!
for example, to make it usable not only for HTML/XML.
Currently, the
define!()
macro assumes XML-like rules, and there's likely a bit of overhead in parsing every string in that manner. I have use for templating for a wide range of formats which are not XML-like in nature, such as INI, TOML, or any other custom formats. Peppering thedefine!()
withmarkup::raw()
seems wrong.As an example, this is what I've come up with for generating desktop entry files. There are no escape rules, outside of
\;
for in keys that take multiple values.