One of these perhaps
•If-then-else ◦contains(val, pattern, text if match, text if not match)
◦ifempty(val, text if empty)
◦test(val, text if not empty, text if empty)
•Iterating over values ◦first_non_empty(value, value, ...)
◦lookup(val, pattern, field, pattern, field, ..., else_field)
◦switch(val, pattern, value, pattern, value, ..., else_value)
•List lookup ◦identifier_in_list(val, id, found_val, not_found_val)
◦in_list(val, separator, pattern, found_val, not_found_val)
◦list_item(val, index, separator)
◦select(val, key)
◦str_in_list(val, separator, string, found_val, not_found_val)
•List manipulation ◦count(val, separator)
◦list_difference(list1, list2, separator)
◦list_equals(list1, sep1, list2, sep2, yes_val, no_val)
◦list_intersection(list1, list2, separator)
◦list_re(src_list, separator, search_re, opt_replace)
◦list_sort(list, direction, separator)
◦list_union(list1, list2, separator)
◦subitems(val, start_index, end_index)
◦sublist(val, start_index, end_index, separator)
http://manual.calibre-ebook.com/template_ref.html#id39
Helen