maghoff / bart

A compile time templating language for Rust inspired by Mustache
https://crates.io/crates/bart
MIT License
37 stars 7 forks source link

Implement Conditional for Option<T> #24

Closed dbrgn closed 1 year ago

dbrgn commented 1 year ago

I found the https://github.com/maghoff/bart/blob/master/src/conditional.rs module through #10. Would it be possible to implement this for Option<T> as well, e.g. Option<String>?

maghoff commented 1 year ago

Hi! Thanks for getting in touch!

It's been a long time since I have had the opportunity to touch this project. My immediate reaction is to recommend the use of iteration instead. So, you're asking for support for syntax like this: {{#the_option?}}The Option is Some(...){{/the_option}}. Would it be sufficient for you to use {{#the_option}}The Option is Some(...){{/the_option}} instead? If not, can you please elaborate on what you need and the differences you need as compared to this iteration possibility?

(See also the test that uses iteration on an Option)

dbrgn commented 1 year ago

Ah. Yeah, you're right, I wasn't aware that this works 🙂 Thanks for pointing it out.