View Single Post
Old 03-17-2025, 02:13 PM   #20
DrChiper
Bookish
DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.DrChiper ought to be getting tired of karma fortunes by now.
 
DrChiper's Avatar
 
Posts: 1,030
Karma: 2003162
Join Date: Jun 2011
Device: PC, t1, t2, t3, Clara BW, Clara HD, Libra 2, Libra Color, Nxtpaper 11
Quote:
Originally Posted by chaley View Post
This is called "shortcutting".
Right. I knew its behavior, but can't remember whether I have heard this name before.

Quote:
Originally Posted by chaley View Post
FWIW and perhaps doing premature optimization: this will be a bit faster because
  1. a) local variables are faster than field lookups, and
  2. b) switch_if is faster than a series of ifs.
Good to know. I used to use local variables but was not sure whether they were to be preferred within calibre or not.

Quote:
Originally Posted by chaley View Post
Code:
	switch_if(
		title_neq && authors_neq, 'true1, true2',
		title_neq, 'true1',
		authors_neq, 'true2',
		'false')
The good old "WITH" statement Yes, I was looking to something similar, but was to lazy to RTFM (I do just occasionally some small coding effort within calibre, when the need arises that is)

Well the Template Catalog Plugin seems interesting (I had indeed asked myself how to control all those templates defined at various places) but this might help a lot.

Perhaps now a description about the do's and don't's of template creation, anybody?
DrChiper is offline   Reply With Quote