OK, I understand. You want a template that returns something like "yes" (or in your case an icon file name) for a book if that book would match a particular search expression.
Although this is possible to do and probably isn't intellectually difficult, it would be very tedious. It would need to understand the search syntax in all its glory (regexps, ranges, etc) and be able to translate these into an equivalent template expression. As this isn't something I would ever use, I don't want to spend the many days to build it.
FYI and to give some idea of the complexity: the template for your example would be something like
Code:
program:
# pubdate:<=1922-1-1 and formats:"=PDF" and tags:"=Historical"
test(
and(
strcmp(
format_date(raw_field('pubdate'), 'yyyy-MM-dd'),
'1922-01-01',
'y', 'y', ''),
in_list(approximate_formats(), ',', 'pdf', 'y', ''),
in_list(field('tags'), ',', '^Historical$', 'y', '')
),
'yes',
'no')
This isn't hard for a human to work out, but the translating program would need to know things like when to use field lookup vs raw_field vs like approximate_formats, how to deal with dates, and when to use anchors on the match patterns.