Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 12-22-2020, 07:05 AM   #1
un_pogaz
Chalut o/
un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.
 
un_pogaz's Avatar
 
Posts: 439
Karma: 145424
Join Date: Dec 2017
Device: Kobo
Template : IF code is correct?

So I looked at the code of the Template function (for build a 'IFELSE') and I just saw the 'IF' code is that:
Code:
def evaluate(self, formatter, kwargs, mi, locals, x, y, re):
    if val:
        return val


It's very strange, it shouldn't rather be :
Code:
def evaluate(self, formatter, kwargs, mi, locals, x, y, re):
    if x == y:
        return re
calibre 5.7.2

(I sincerely hope I'm wrong, otherwise there's a very old bug.)
un_pogaz is offline   Reply With Quote
Old 12-22-2020, 09:17 AM   #2
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,440
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
What exactly are you looking at?

The line
Code:
def evaluate(self, formatter, kwargs, mi, locals, x, y, re)
doesn't exist in calibre.

The lines
Code:
if val:
        return val
exist in the ifempty function, and are correct.
chaley is offline   Reply With Quote
Advert
Old 12-22-2020, 10:21 AM   #3
un_pogaz
Chalut o/
un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.
 
un_pogaz's Avatar
 
Posts: 439
Karma: 145424
Join Date: Dec 2017
Device: Kobo
My bad. My bad.
This function "IF(x, y, re)" is a custom function. I have no idea how it got into my Caliber parameters, as this is the first time I create Template functions.
un_pogaz is offline   Reply With Quote
Old 12-22-2020, 10:27 AM   #4
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,440
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by un_pogaz View Post
My bad. My bad.
This function "IF(x, y, re)" is a custom function. I have no idea how it got into my Caliber parameters, as this is the first time I create Template functions.
Thanks for telling me.

BTW: the template language supports if/then/else. It is evaluated directly by the template processor (inlined) and has much better performance than a function.
chaley is offline   Reply With Quote
Old 12-22-2020, 10:32 AM   #5
un_pogaz
Chalut o/
un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.
 
un_pogaz's Avatar
 
Posts: 439
Karma: 145424
Join Date: Dec 2017
Device: Kobo
Quote:
Originally Posted by chaley View Post
BTW: the template language supports if/then/else. It is evaluated directly by the template processor (inlined) and has much better performance than a function.
Oh, perfect, Thanks
un_pogaz is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
"Normal" template inside GPM template ownedbycats Library Management 20 12-02-2020 09:40 PM
Using built-in template functions in a custom template function ilovejedd Library Management 4 01-28-2018 12:20 PM
Multiple conditions in TEMPLATE code HFC3 Library Management 4 07-07-2013 01:39 PM
Graphical layout vs. semantically "correct" XHTML code Iznogood Workshop 16 04-05-2011 08:14 AM
Let's create a source code repository for DR 800 related code? jraf iRex 3 03-11-2010 12:26 PM


All times are GMT -4. The time now is 06:39 PM.


MobileRead.com is a privately owned, operated and funded community.