Quote:
Originally Posted by ownedbycats
For what it matters, the actual template has quite a few individual entries, e.g.:
Code:
program:
f = field('#fanficcat');
strcat
(
contains(f, "Fallout", 'fallout.png:', ''),
contains(f, "Half-Life", 'halflife.png:', ''),
contains(f, "Mass Effect Trilogy|Mass Effect: Andromeda", 'masseffect.png:', ''),
(at least a dozen more like this)...
contains(f, "^(2001: A Space Odyssey|Alien|Short Circuit)$", 'Film.png:', ''),
)
I just combine the miscellaneous one into generic film/book/videogame icons. Since it's a stored template both the column icons and emblems get updated.
Since I want to display all the relevant icons, I'm not sure that an if statement would work too well. But would list_contains be appropriate?
|
Yes, given the above you want list_contains(), not contains().
In this context the if is the same as a function call. Both are expressions that return a value. You can have as many as you want, and you can intermix them. In other words, this works:
Code:
program:
f = $tags;
strcat(
if '^Fallout$' in f then 'fallout.png:' fi,
list_contains(f, ',', '^Half-Life$', 'halflife.png:', ''),
if "^(Mass Effect Trilogy|Mass Effect: Andromeda)$" in f then 'masseffect.png:' fi
)
The 'if' is slightly faster because it is directly executed by the formatter. list_contains() is a template function call that is not inlined.