Quote:
Originally Posted by kacir
I really like the template language and conditional fields.
You might consider adding another example to the documentation
Code:
{author_sort}/{series}/{series}{series_index:0>3s|[|] - }{title} - {authors}
so the result would be
Code:
Asimov, Isaac/Foundation series/Foundation series[001] - The Foundation - Isaac Asimov
This example demonstrates that you can use conditional prefix, suffix with formatting of the series number
I was trying to test how some ... aehm ... not-very-obvious ... combinations in Templates work ;-)
|
I have already added the example:
Code:
For example, assume you want to use the template::
{series} - {series_index} - {title}
If the book has no series, the answer will be ``- - title``. Many people would rather the result be simply ``title``, without the hyphens. To do this,
use the extended syntax ``{field:|prefix_text|suffix_text}``. When you use this syntax, if field has the value SERIES then the result will be
``prefix_textSERIESsuffix_text``. If field has no value, then the result will be the empty string (nothing); the prefix and suffix are ignored. The prefix and
suffix can contain blanks.
Using this syntax, we can solve the above series problem with the template::
{series}{series_index:| - | - }{title}
The hyphens will be included only if the book has a series index, which it will have only if it has a series.
That seems to demonstrate what you are suggesting.
Quote:
Also, there seems to be a typo in documentation
- extra {} around author in the result
- extra space dash space ' - ' in the result between 'Second foundation' and series number.
|
Thanks. Fixed.
FYI: In the next release, you will be able to use both formatting specifications and functions. Using this, the following will work to ensure that zero values are printed. The relevant doc section is
Code:
Now, about using functions and formatting in the same field. Suppose you have an integer custom column called ``#myint``
that you want to see with leading zeros, as in ``003``. To do this, you would use a format of ``0>3s``. However, by default, if a number (integer
or float) equals zero then the field produces the empty value, so zero values will produce nothing, not ``000``. If you really want to see ``000`` values,
then you use both the format string and the ``ifempty`` function to change the empty value back to a zero. The field reference would be::
{#myint:0>3s:ifempty(0)}
Note that you can use the prefix and suffix as well. If you want the number to appear as ``[003]`` or ``[000]``, then use the field::
{#myint:0>3s:ifempty(0)|[|]}