This commit is contained in:
Kovid Goyal 2024-03-13 19:35:53 +05:30
commit 1f1e352b75
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 10 additions and 2 deletions

View File

@ -671,7 +671,7 @@ class Parser(SearchQueryParser): # {{{
matches = set()
error_string = '*@*TEMPLATE_ERROR*@*'
template_cache = {}
global_vars = {}
global_vars = {'_candidates': candidates}
for book_id in candidates:
mi = self.dbcache.get_proxy_metadata(book_id)
val = mi.formatter.safe_format(template, {}, error_string, mi,

View File

@ -294,7 +294,15 @@ def create_template_tab(self):
self.template_program_box = le = TemplateLineEditor(self.tab_widget)
le.setObjectName('template_program_box')
le.setPlaceholderText(_('The template that generates the value'))
le.setToolTip(_('Right click to open a template editor'))
le.setToolTip('<p>' +
_('Right click to open a template editor. <br>'
'Technical note: the set of book ids already matched by '
'previous search terms in the search expression is passed '
'to the template in the global variables dictionary with the '
'key "{0}". You can use the set to limit any work the '
'template does to the set of books already matched, possibly '
'improving performance.'
).format('_candidates') + '</p>')
lo = QHBoxLayout()
lo.addWidget(le)
self.edit_template_button = tb = QToolButton()