Open Aunmag opened 4 years ago
Probably this issue intersects with https://github.com/kaj/ructe/issues/29
After some experimentation, I have more or less decided against the solution I suggsted in #29, and in favor of something like https://github.com/kaj/ructe/pull/42#issuecomment-510231217 . That would hopefully make it possilble to get your expected output by adding a backslash at the end of selected lines of the template.
Do you think that would suffice?
I'm not sure how it would look like. Like this?
@()
begin\
@for n in &vec![0, 1, 2] {\
@if true {
test\
}}
end
Personally, this approach is not clean enough for me. Maybe I miss something.
Yes, something like that.
Your idea of not generating output for template lines that is only statements would be nice, but a bit harder to implement. Ructe does not look at a template line by line, but would instead have to look at the end of the last thing before a block-opening statement and compare it to the first thing in the block, and similiar for the end of the block (and a special case for "else" blocks).
But I'll keep this issue open and think about it. PR:s welcome, of course.
It would be cool if this template might produce something like:
But to get the same output I have to write the template in this way, and it looks kinda dirty:
So the point is: if a line contains only start or end of an expression, and while spaces or tabs or line-break, then it will be skipped. It will allow to write more readable and intuitive templates.
More examples:
The first one looks better, doesn't it? :)
I hope you will take more attention to Rocker developer's experience, 'cause we need such a great tool in Rust too.