sawhney17 / logseq-smartblocks

MIT License
172 stars 12 forks source link

IF statements output an empty block if false. Would prefer no output when false. #35

Open pixealhead opened 2 years ago

pixealhead commented 2 years ago

Using the <% if time = : %> command outputs an empty block when it is false. Please change it so no block is output when false.

This is especially irritating when you use a large number of them together in an attempt to add tasks based on the day of the week. I just did that on Sunday, which a day that I do not have any if statements setup for (they are only triggered on weekdays) and I ended up with 10 empty blocks.

sawhney17 commented 2 years ago

Very interested in how this would work. I guess this would mean that all sun blocks will also be deleted then? On 18 Jul 2022 at 12:31 AM +0400, pixealhead @.***>, wrote:

Using the <% if time = : %> command outputs an empty block when it is false. Please change it so no block is output when false. This is especially irritating when you use a large number of them together in an attempt to add tasks based on the day of the week. I just did that on Sunday, which a day that I do not have any if statements setup for (they are only triggered on weekdays) and I ended up with 10 empty blocks. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

pixealhead commented 2 years ago

I'm not familiar with what a sun block is, so I'm unable to comment on what should happen with them.

sawhney17 commented 2 years ago

whoops. 😅. I  meant all sub blocks. On 21 Aug 2022 at 2:31 PM +0400, pixealhead @.***>, wrote:

I'm not familiar with what a sun block is, so I'm unable to comment on what should happen with them. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

WesHoward commented 1 year ago

So if the IF statement is on a block with child blocks then it feels like. a TRUE/FALSE is for that whole branch of the tree and the sub blocks under the IF statement should not be rendered unless there is other text on the line that would render - basically 'if line is blank then no children, if line len >0 then include children".

Example: <%if dayofweek = 5: TODO Record Progress for these projects:%>

In this case none of the sub blocks should show as the parent is empty and therefore they are irrelevant.

TODO Send updates to the following teams <%if dayofweek = 5: and my manager%>

In the latter example I should see the children whenever rendered.

In my real life example these are the last 4 lines of my daily routine:

I get a bunch of blank lines at the bottom which i have to remove.