Template: hide symbols if some tag value is blank

Ideas for improvements and requests for new features in XnView MP

Moderators: XnTriq, helmut, xnview

esv
Posts: 37
Joined: Fri Sep 16, 2022 1:04 pm

Template: hide symbols if some tag value is blank

Post by esv »

For templates (e.g., for customizing tooltips) I'd like to be able to hide some separators if the values they separate are empty
For example, currently

Code: Select all

{Tag status} | {Rating} | {Color label}
shows as

Code: Select all

[] | |
when all fields as empty

I'd like to "tie" the "|" symbols to the previous values and don't show them if those values are blank, so for example, if I enter the following mock template

Code: Select all

{Tag status}{≠∅" | "}{Rating}{≠∅" | "}{Color label}
(where {≠∅" | "} means "if the previous tag is not empty, print this string)
I'd get this nice empty field (without any newlines as well, though that would require some other templating feature)
User avatar
xnview
Author of XnView
Posts: 39322
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Template: hide symbols if some tag value is blank

Post by xnview »

Do you have tried

Code: Select all

(({Tag status} | ))(({Rating} | ))(({Color label}))
Pierre.
esv
Posts: 37
Joined: Fri Sep 16, 2022 1:04 pm

Re: Template: hide symbols if some tag value is blank

Post by esv »

No I haven't, I didn't know it existed, where is this documented?

so from testing this

Code: Select all

t{Tag status} | r{Rating} | c{Color label}
((t{Tag status} | ))((r{Rating} | ))((c{Color label}))
get

Code: Select all

t[] | r | c
t[] |
Good news is that the Rating/Color tags seem to disappear, but the status remains
Also, is there a similar trick for the newline char? Can I completely remove the line if it's empty, something like this doesn't seem to work, I always get a newline

Code: Select all

(((((r{Rating} | ))((c{Color label}))<br>))