Conditional brackets if a tag has a value?

Frustrating; I knew how to do this, but my brain seems to be in a wrong groove that at this moment I can’t get out of, so I am calling out for some quick-support:

Suppose I want a tag to show something like: Title <language>

Then this will work fine:
$set(A Tag,%title% <%language%>)

But if there is no content for ‘language’, it will display:
Title <>
and obviously I don’t want the <> brackets to show if there is no content for ‘language’.

I thought to do something like this:
$set(A Tag,%title% $if(language,<%language%>,))
but that won’t work. It will still output the <> brackets even if there is no ‘language’.

Somebody kick me into the right track?

Try enclosing the first language in the $if() block in percent signs, as:

$set(A Tag,%title%$if(%language%, <%language%>,))
1 Like

I knew beforehand the answer would make me feel stupid :wink:
Thanks again…

No problem. I do that sort of thing myself pretty much every day. I’m currently updating the scripting documentation (including adding examples for each function), and it often takes three or four tries to get an example working properly because I either include the "%"s when I shouldn’t (for example, on some of the multi-value functions), or forget them when I should.

3 Likes

That’s surely some comfort :wink:
I’m pretty sure I had the percentages (probably a $get) there when starting out with the more complicated script I was trying to use it in, but it didn’t work well, and in the process of trying out all sorts of solutions, the percentages must have gotten lost without me noticing or thinking about it.

Thanks for the fresh eyes and the quick support.