View Single Post
Old 08-06-2011, 12:24 PM   #4
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,461
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by gers1978 View Post
3) Set the Template field to "{series:|({author}) |}"
Using template items inside template items can lead to very strange results. The fact that it works at all is a bug that I haven't fixed because it can be useful in the right context. The problem is that the value of the subitem will be rescanned in the context of the containing item as if it had been hand-typed there. Special characters such as | and {} and : inside the subitem will greatly confuse the scanning of the containing item.

If you can guarantee that the subitem ({authors} in this case) will never contain any of the characters { } | and possibly " and ', then there is no problem.

The following template avoids this problem by using template program mode instead of a sub-item.
Code:
{series:'test($, strcat('(', field('authors'), ') ', $), '')'}
If series has a value, then return the desired string built by concatenating together the parts, otherwise return the empty string.
chaley is offline   Reply With Quote