Hi there. I’m working on a pluralize macro, which should output the correct form of the given English-language noun based on the value of the count variable.
- If its value is
1, it should output the singular form; otherwise, it should output the plural form. - Eg.
<<pluralize 9 spoon spoons>>should give9 spoons, while<<pluralize 1 boat boats>>should give1 boat.
It seems to work when the value for count is a plain or hard-coded value, but not when it’s calculated.
I’d really appreciate an explanation of why this is happening, much more than a practical solution. I feel like I’m missing a fundamental of how macros, variables and rendering work. Please help 
A. Macros & View
\define age-from-birthday()
<$let now={{{[<now TIMESTAMP>]}}} birthday={{{ [{!!birthday}format:date[TIMESTAMP]] }}} age={{{[<now>subtract<birthday>divide[31536000000]floor[]]}}}><<age>></$let>
\end
\define pluralize(count, singular, plural)
<!--//DEBUG: I got count='<<__count__>>', singular=<<__singular__>>, plural=<<__plural__>>. Is it 1? {{{ [<__count__>match[1]then[yes]else[no]] }}}//-->
<% if [<__count__>compare:number:eq[1]] %>
<<__singular__>>
<% else %>
<<__plural__>>
<% endif %>
\end
\define years-old-string()
<<age>> <<pluralize "$(age)$" "year" "years">> old
\end
!! Age as a plain value
<ul>
<$list filter=[[Charlie]]>
<$let age=1>
<li>{{!!title}} is {{!!age}} <<years-old-string>></li>
</$let>
</$list>
</ul>
!! Age as a calculated value
<ul>
<$list filter=[[Alice]][[Bob]]>
<$let age={{{ [<age-from-birthday>] }}}>
<li>{{!!title}} is {{!!age}} <<years-old-string>></li>
</$let>
</$list>
</ul>
B. Data
- Tiddler
Alicewith field birthday =20241212120000000– one year old - Tiddler
Bobwith field birthday =20000303120000000– 25 years old - Tiddler
Charlieneed not exist; I am only using the name, and a hard-codedageof1. - Today is a date in December, 2025.
C. Output
Age as a plain value
- Charlie is 1 year old [this is correct]
Age as a calculated value
- Alice is 1 years old [this is incorrect]
- Bob is 25 years old