Closed miguelski closed 3 years ago
May be possible with bailout conditions div[class=css?] and have the codegen put it in its own
let _: Option<()> = {
Some(writer.write("<div class=\"{}\">", css?))
}.transpose()?;
but seems like a fair bit more work and codegen
@ZaneHannanAU misread the original...isn't quite so simple. The class="" shouldn't be too bad outside of looking like php.
reading the code it should work,
i make it work but if the variable is Option
i think the issue is in the above methods. is_none
when used &Option is always false and is_false
is always false if a &boolean is passed instead a boolean
Thanks for reporting the issue and figuring out the solution @miguelski! Can you please try out the latest version from git to confirm this fixes your code before I make a release (I have added tests, but just to be sure)?
[dependencies]
markup = { git = "https://github.com/utkarshkukreti/markup.rs" }
working for me, thank you
Awesome, published 0.12.1.
problem: i am migrating a project from horrorshow currently there are some Option variables for example
let css: Option<String> = None;
but i don't find a way to specify that if css is None don't create the html attributediv[class=css]
creates<div class=""></div>
but i want create when css is None<div></div>
i know i can do an if conditional like thisbut this is not practical when i have a lot of optional attributes
horrorshow have this sintaxis
div(class?=css)
and i get what i want<div></div>
when css is Noneis there something similar that i missing? or it would be a new feature?