Thread: Custom Coloring
View Single Post
Old 05-29-2011, 09:10 AM   #15
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,466
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by jesscat View Post
Another question for you: can you test on the ondevice field? If so, what happens if there is no device connected? Or do you first have to check to see if that field exists?
Currently the ondevice field cannot be used in templates. There are issues with making it a normal template field.

However, it is clearly useful to be able to use ondevice in color templates, so I have added a new template function, ondevice(), to fetch its value. This function should appear in the next release, earlier if you run from source. The function returns 'Yes' (translated if not running in English) if a device is connected and the book is on that device. It returns the empty string if the book is not on the device or if a device is not connected.

You can use the ondevice function where you would use field('ondevice') if only ondevice were a real field. You can also use it in template function mode as {:'ondevice()'} (the field name is omitted).
chaley is offline   Reply With Quote