mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Template language: Make all column names case insensitive
This commit is contained in:
parent
9fcf243a72
commit
7918f0c075
@ -38,15 +38,16 @@ class SafeFormat(TemplateFormatter):
|
||||
|
||||
def get_value(self, key, args, kwargs):
|
||||
try:
|
||||
key = key.lower()
|
||||
if key != 'title_sort':
|
||||
key = field_metadata.search_term_to_field_key(key.lower())
|
||||
key = field_metadata.search_term_to_field_key(key)
|
||||
b = self.book.get_user_metadata(key, False)
|
||||
if b and b['datatype'] == 'int' and self.book.get(key, 0) == 0:
|
||||
v = ''
|
||||
elif b and b['datatype'] == 'float' and self.book.get(key, 0.0) == 0.0:
|
||||
v = ''
|
||||
else:
|
||||
ign, v = self.book.format_field(key.lower(), series_with_index=False)
|
||||
ign, v = self.book.format_field(key, series_with_index=False)
|
||||
if v is None:
|
||||
return ''
|
||||
if v == '':
|
||||
|
@ -468,6 +468,7 @@ class EvalFormatter(TemplateFormatter):
|
||||
A template formatter that uses a simple dict instead of an mi instance
|
||||
'''
|
||||
def get_value(self, key, args, kwargs):
|
||||
key = key.lower()
|
||||
return kwargs.get(key, _('No such variable ') + key)
|
||||
|
||||
eval_formatter = EvalFormatter()
|
||||
|
Loading…
x
Reference in New Issue
Block a user