Quote:
Originally Posted by asogn
OK, was able to figure it out. Had some problems due to apostrophe, but following works for me:
Code:
{#kindlecollections:'contains($,'^x_*',field('#kindlecollections'),"{#universe:'ifempty($, field('author_sort'))'}{series:| - |}")'}
Cheers, Atle
|
That template will at some point not work, depending on the values in #universe or series. The problem: bracketed expressions are macros, evaluated before the template is parsed. Thus if #universe or series can contain a character that can affect parsing, most notably " or ' but other characters as well, then the template will fail. Also, nesting Template Program Mode expressions is problematic.
If you want to nest templates or TPM expressions then you should use
General Program Mode where no macro processing takes place. They are also easier to read when dealing with this level of complexity. Something like:
Code:
program:
u = ifempty(field('#universe'), field('author_sort'));
s = finish_formatting(field('series'), '', ' - ', '');
kc = field('#kindlecollections');
contains(kc, '^x_*', kc, strcat(u, s))
I can't test it because I don't have your columns.
FWIW: I suspect that the regexp you use in the 'contains' isn't what you really want. That regexp looks for a leading x followed by zero or more underscores. I thing you want '^x_', which is a leading x followed by an underscore.