I did a proof of concept implementation using the code from the template functions implementation. It works.
Given the following template:
Code:
python:
def evaluate(self, mi, db):
print(mi.authors)
s = self.get_default_if_none(mi, 'series', '**no series**')
return s + ':::' + str(self.get_default_if_none(mi, '#myint', 999))
def get_default_if_none(self, mi, field, default):
v = mi.get(field, None)
return default if v is None else v
The screen capture shows what I get in the template tester. The template tester still highlights strings and matching parentheses.
This isn't close to done. For example it doesn't include caching, error handling, or pulling the db out of the mi instance.