View Single Post
Old 02-20-2024, 01:31 AM   #1
tgiladi
Enthusiast
tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.tgiladi can even cheer up an android equipped with a defective Genuine Personality Prototype.
 
Posts: 35
Karma: 30486
Join Date: Dec 2023
Device: Kindle Oasis
Template language - Conditionally including text

Hi,
I followed the instructions here: https://manual.calibre-ebook.com/template_lang.html and successfully managed to set the save to disk setting to my preferences:
Code:
{series} {series_index:0>2s|#| - }{title} - {authors}
This works very well when saving to disk, so I thought I could use the same technique when customizing my jacket.xhtml template. What I am trying to achieve is having the book's name in it's original language, below the Ttitle. For this I am using a custom column, and I am able to show it without issue if there is data in that column. But what I can't figure out how to do is to have that name in parenthesis like so: (original name). If I add parenthesis to the code, then they would show anyway, even if there is no data in the custom column. I tried this code:
Code:
{_original_name:|(|)}
but it is not working and I get an error when I try to polish the book with this code: ValueError: Invalid format specifier '|(|)' for object of type 'str'

Is there another way to include the parenthesis around the conditional text only if there is data in the custom column?
tgiladi is offline   Reply With Quote