View Single Post
Old 01-07-2023, 07:48 PM   #460
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,841
Karma: 62032373
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Thanks.

I converted one of my templates to get a better idea of how the switch_if works. Is this a good place to use one?

Code:
program:
	switch_if(
		'Cleanup' in virtual_libraries(), 'polish.png',
		'Fanfiction' in $#booktype, list_split(icons_fanfic(), ':', 'ff'); 
			ff_0,
		'Documentations & Manuals' in $#booktype, 'helpbook.png',
		'Loans' in virtual_libraries(), 'overdrive.png',
		'Physical Books' in virtual_libraries(), 'paperbook.png',
		approximate_formats()=='PDF', 'pdfbook.png',
		'omnibus' inlist $#admintags, 'bookshelf.png',
		'book_open.png',
	)
original first_non_empty template:
Spoiler:
Code:
program:
	first_non_empty(
		if 'Cleanup' in virtual_libraries() then 'polish.png' fi,
		if 'Fanfiction' in $#booktype then 
			list_split(icons_fanfic(), ':', 'ff'); 
		ff_0 fi,
		if 'Documentations & Manuals' in $#booktype then 'helpbook.png' fi,
		if 'Loans' in virtual_libraries() then 'overdrive.png' fi,
		if 'Physical Books' in virtual_libraries() then 'paperbook.png' fi,
		if approximate_formats()=='PDF' then 'pdfbook.png' fi,
		if 'omnibus' inlist $#admintags then 'bookshelf.png' fi,
		'book_open.png',
	)


(at times like this, sometimes I wish there was some sort of split template editor so I could compare the results of two templates. That's probably not too useful generally though.)

Last edited by ownedbycats; 01-07-2023 at 07:51 PM.
ownedbycats is offline   Reply With Quote