Quote:
Originally Posted by ownedbycats
That worked.
Tweaking my #kobopath template:
[...]
Based on that second disadvantage, I'm inclined to go with option #1. Does this make sense?

|
I would avoid complexity and make the checks explicit. The new switch_if() makes it easy and compact to do the checks in order. Something like this:
Code:
program:
# Returns 'Fanfiction/Fandom' tag for fanfics
booktype = 'Fanfiction';
tags = 'Fanfiction.Bar, Fanfiction.Crossover, Fanfiction.Foo';
if booktype == 'Fanfiction' then
switch_if(
'^Fanfiction\.Crossover$' inlist tags, 'Fanfiction/Crossover',
# More tests in the order you want
'^Fanfiction\.Foo$' inlist tags, 'Fanfiction/Foo',
# ...
# If none of the tests find a value then end up picking the first one.
# If the list is empty then this will return the empty string.
# You only need the list_re() if the list can contain values other than
# Fanfiction.XXX.
list_item(list_re(tags, ',', '^Fanfiction.(.*)$', 'Fanfiction/\1'), 0, ',')
)
fi