+1 vote
by (8.9k points)

I have this widget, which displays "mom" for North Americans, and "mum" for everybody else:

<<widget "mom">><<nobr>>
<<if $pc.nationality == "U.S." or $pc.nationality == "Canadian">>
mom
<<else>>
mum
<</if>>
<</nobr>><</widget>>

Is it possible to run this widget in an array?  I tried:

<<set $parentsSeparatedBecause to [
         "dad abandoned <<mom>>",
         "<<mom>> left dad",
         "dad died before you were born"]>>

But it just displays <<mom>> in the output.

1 Answer

+1 vote
by (8.6k points)
selected by
 
Best answer

Interesting, because your code ...

<<set $parentsSeparatedBecause to [
         "dad abandoned <<mom>>",
         "<<mom>> left dad",
         "dad died before you were born"]>>

... shouldn't display anything.

What you likely want is to print (one element of) your array evaluating it. This is typically done with the "<<= ....>>" macro. Compare the two outputs here:

<<set $pc = {nationality: "Barsoonian"}>>
<<set $parentsSeparatedBecause to [
         "dad abandoned <<mom>>",
         "<<mom>> left dad"]>>

<<- $parentsSeparatedBecause.random()>> - <<= $parentsSeparatedBecause.random()>>

 

...