03-27-2022, 01:02 PM | #76 |
Custom User Title
Posts: 9,099
Karma: 62844063
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
That will be useful. thank you
|
04-25-2022, 06:53 AM | #77 |
Grand Sorcerer
Posts: 11,868
Karma: 7036359
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
New template function list_join()
25 April 2022 (In calibre source)
Last edited by chaley; 04-25-2022 at 07:13 AM. |
Advert | |
|
04-25-2022, 11:28 AM | #78 |
Custom User Title
Posts: 9,099
Karma: 62844063
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
What would be the difference between this and list_union? I believe the latter doesn't have the additional expressions, at least.
|
04-25-2022, 11:31 AM | #79 | |
Grand Sorcerer
Posts: 11,868
Karma: 7036359
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
|
|
04-25-2022, 12:33 PM | #80 |
Custom User Title
Posts: 9,099
Karma: 62844063
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I have a couple of column-update templates that use list_union so I'll give it a try.
|
Advert | |
|
05-13-2022, 02:28 PM | #81 | |
Grand Sorcerer
Posts: 11,868
Karma: 7036359
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Template looping over an integer range
The template language can now loop over an integer range using a new range() function.
The (condensed) grammar for loops over lists and integers is: Code:
for_expr ::= for_list | for_range for_list ::= 'for' identifier 'in' list_expr [ 'separator' separator_expr ] ':' expression_list 'rof' for_range ::= 'for' identifier 'in' range_expr ':' expression_list 'rof' range_expr ::= 'range' '(' [ start_expr ',' ] stop_expr [ ',' step_expr [ ',' limit_expr ] ] ')' Code:
current_value + step_expr >= stop_expr In the context of a for loop the list isn't actually generated, improving performance and memory usage. In any other context the range() function generates and returns the list. Example: this loop uppercases every second letter in the title: Code:
program: res = ''; for i in range(strlen($title)): c = substr($title, i, i+1); res = strcat(res, if mod(i, 2) == 0 then uppercase(c) else c fi) rof Code:
program: res = ''; for i in range(0, strlen($title), 1, 100): c = substr($title, i, i+1); res = strcat(res, if mod(i, 2) == 0 then uppercase(c) else c fi) rof Code:
program: t = $title; res = ''; for i in range(strlen(t)): c = lowercase(substr(t, i, i+1)); if '\w' in c then res = list_join(',', res, ',', c, ',') fi rof; list_count(res, ',') Quote:
|
|
06-05-2022, 05:05 PM | #82 |
Grand Sorcerer
Posts: 11,868
Karma: 7036359
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
New template function urls_from_identifiers()
26 May 2022 (In calibre version 5.43)
|
07-04-2022, 09:42 AM | #83 |
Grand Sorcerer
Posts: 11,868
Karma: 7036359
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Two new template functions: book_count() and book_values()
04/July/2022 (in calibre 6.0)
Last edited by chaley; 07-11-2022 at 10:28 AM. |
07-12-2022, 12:24 PM | #84 |
Grand Sorcerer
Posts: 11,868
Karma: 7036359
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Internal changes - better use of the database
I changed the way the template functions use the database to improve reliability when simultaneously using multiple databases, to decouple the functions from the gui, and to permit more functions to be used for columns to be displayed in the content server.
These changes are in calibre source now. Would those of you who run from source pull the latest and let me know if any behavior changed for the worse? |
07-12-2022, 12:50 PM | #85 |
Custom User Title
Posts: 9,099
Karma: 62844063
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Anything in specific you want testing? Using only one library, everything seems to be working fine at first glance.
|
07-12-2022, 12:56 PM | #86 | |
Grand Sorcerer
Posts: 11,868
Karma: 7036359
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
BTW: I tried them all before I submitted the source. |
|
07-12-2022, 01:37 PM | #87 |
Custom User Title
Posts: 9,099
Karma: 62844063
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
annotation_count(), connected_device_name() (and uuid), current_virtual_library_name(), is_marked(), and virtual_libraries() all are working as expected.
|
07-12-2022, 01:49 PM | #88 |
Grand Sorcerer
Posts: 11,868
Karma: 7036359
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
07-13-2022, 07:38 AM | #89 |
Grand Sorcerer
Posts: 11,868
Karma: 7036359
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
"Secret" template processing tweaks
There are two hidden (plugin) tweaks that affect the template processor:
|
07-18-2022, 06:00 AM | #90 | |
Chalut o/
Posts: 415
Karma: 145424
Join Date: Dec 2017
Device: Kobo
|
Quote:
But how do I use it? I add "show_stack_traces_in_formatter = False" in any tweark configuration or I edit directly "tweaks.json" ? |
|
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
A few questions... (template language, mainly) | Clem2605 | Library Management | 2 | 12-30-2020 03:25 AM |
Template Language | phossler | Calibre | 8 | 01-12-2016 04:37 PM |
Help needed with template language | Mamaijee | Devices | 12 | 02-19-2013 01:52 AM |
Help with template language | Pepin33 | Calibre | 8 | 11-11-2012 08:32 AM |
Template language question | BookJunkieLI | Library Management | 7 | 02-02-2012 06:55 PM |