28 Oct 2024 (in calibre 7.21)
- Improvement to template function has_notes. It now has two variants.
- has_note(field_name, field_value) -- if field_value is not '' (the empty string) , return '1' if the value field_value in the field field_name has an attached note, otherwise ''. Example:
Code:
has_note('tags', 'Fiction')
returns '1' if the tag "fiction" has a note, otherwise ''.
- (NEW) has_note(field_name, '') -- if the second parameter is '' then return a list of values in field_name that have a note. If no item in the field has a note, return ''. Example:
Code:
has_note('authors', '')
returns a list of authors that have notes, or '' if no author has a note.
For example, the second variant is useful for showing column icons if any value in the field has a note rather than a specific value.
You can also test if all the values have a note by comparing the list length of this function's return value against the list length of the values in field_name. Example:
Code:
list_count(has_note('authors', ''), '&') ==# list_count_field('authors')