Skip to content

Clarify %if template behavior#6399

Open
emiham wants to merge 4 commits intobeetbox:masterfrom
emiham:master
Open

Clarify %if template behavior#6399
emiham wants to merge 4 commits intobeetbox:masterfrom
emiham:master

Conversation

@emiham
Copy link
Contributor

@emiham emiham commented Feb 27, 2026

Description

Fixes #4991.

I don't know if there's a single, good workaround for this, so I opted to not add an example solution.

To Do

  • Documentation. (If you've added a new command-line flag, for example, find the appropriate page under docs/ to describe it.)
  • Changelog. (Add an entry to docs/changelog.rst to the bottom of one of the lists near the top of the document.)
  • Tests. (Very much encouraged but not strictly required.)

@emiham emiham requested a review from a team as a code owner February 27, 2026 16:43
Copy link
Contributor

@Serene-Arc Serene-Arc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good clarification for the behaviour you had a problem with, but I wonder if this is something that only makes sense for programmers. Then again, this might be something that only programmers or people somewhat familiar with programming conventions understand. Might not be a problem in that case.

Perhaps make it clear that for different data types, some are always interpreted as False. 0 is that for an integer, False for a boolean, '' for a string, etc.

@emiham
Copy link
Contributor Author

emiham commented Mar 2, 2026

This is a good clarification for the behaviour you had a problem with, but I wonder if this is something that only makes sense for programmers. Then again, this might be something that only programmers or people somewhat familiar with programming conventions understand. Might not be a problem in that case.

I agree that it might be confusing to some people not having the prerequisite programming knowledge, but I still think those people would be better off with more documentation that can at least point them in the right direction/help them ask the right questions when asking for help.

Perhaps make it clear that for different data types, some are always interpreted as False. 0 is that for an integer, False for a boolean, '' for a string, etc.

This is a great point, I had not considered this at all! I can't figure out where in the code the path format actually gets interpreted, do you think you could point me to that? I did try importing two albums named "False" and "false", which both evaluate as False, so that should definitely also be mentioned. I'm curious about what other values might run into this though. Edit: I found the relevant code.

Copy link
Member

@snejus snejus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding some examples for the %if function behaviour, following what we have under %first{text,count,skip,sep,join} below?

@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.39%. Comparing base (edbf737) to head (bd3e52b).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6399   +/-   ##
=======================================
  Coverage   69.39%   69.39%           
=======================================
  Files         141      141           
  Lines       18816    18816           
  Branches     3068     3068           
=======================================
  Hits        13057    13057           
  Misses       5112     5112           
  Partials      647      647           
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@emiham
Copy link
Contributor Author

emiham commented Mar 6, 2026

I've changed the wording to explicitly mention which values are interpreted as false, so I think it should be clear for people without programming knowledge now as well.

Would you mind adding some examples for the %if function behaviour, following what we have under %first{text,count,skip,sep,join} below?

I wouldn't mind doing this, but I can't think of what examples to add. My personal use case was the same as yours, i.e. creating an album only if the album field is populated, but I don't think that should be recommended unless you also add a workaround for albums with falsy names.

@emiham emiham requested review from Serene-Arc and snejus March 6, 2026 09:15
@snejus
Copy link
Member

snejus commented Mar 6, 2026

Sounds good to me - now just rebase it on master and run poe format-docs to satisfy the CI.

@emiham
Copy link
Contributor Author

emiham commented Mar 6, 2026

That's weird, I did run poe format-docs. I just tried again and it doesn't report anything, even though the CI fails.

@snejus
Copy link
Member

snejus commented Mar 6, 2026

Interesting. I have just ran it on my end and it does indeed reformat pathformat.rst. Maybe try running poetry install to make sure the dependencies are in sync and re-run the command again?

@snejus snejus dismissed Serene-Arc’s stale review March 6, 2026 20:20

The change has been implemented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Variant of %if template function that does not treat 0 as false

3 participants