Possible? certainly.
Advisable? depends.
- PTM templates will be faster, but in the case of emblems it probably doesn't matter all that much. The template is evaluated when a cover is shown, with the result cached until metadata is changed. You might see a performance difference scrolling at full speed through the covers, but I doubt it. However, even very small performance improvements can matter if the template can be used when sorting or searching.
- The first template is simple enough where we are talking about nanoseconds of difference, perhaps a 100 or so. The second will see more improvement because PTM can deal directly with the list of formats without converting it to a comma-separated list, and because it avoids using a regular expression search.
- You should understand the template well enough to maintain it.
As for the templates themselves ...
Code:
program:
test($#last_viewed, 'lastop-dark.png', '');
What column type is #last_viewed? The template below works if it is a date. Tags-like fields would use a different return statement because for empty values book.get() returns an empty list instead of 'None'.
Code:
python:
def evaluate(book, context):
date = book.get('#mydate')
return 'lastop-dark.png' if date is not None else ''
As for
Code:
program:
test(contains(field('formats'), "EPUB", '1', ''), 'logo epub.png', '');
This is the equivalent PTM template:
Code:
python:
def evaluate(book, context):
formats = book.get('formats')
return 'logo epub.png' if formats is not None and 'EPUB' in formats else ''