mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Merge branch 'master' of https://github.com/cbhaley/calibre into master
Fixes #1900316 [Rewrite example in documentation for translations](https://bugs.launchpad.net/calibre/+bug/1900316)
This commit is contained in:
commit
17e6846cbe
@ -437,13 +437,16 @@ Example: the following SFM template returns either the series name or the string
|
||||
|
||||
{series:ifempty(no series)}
|
||||
|
||||
The equivalent templates in TPM and GPM are::
|
||||
The equivalent template in TPM is ::
|
||||
|
||||
TPM: ``{series:'ifempty($, 'no series')'}
|
||||
GPM: ``program: ifempty(field('series'), 'no series')``
|
||||
``{series:'ifempty($, 'no series')'}``
|
||||
|
||||
The first argument to ``ifempty`` is the value of the field ``series`` and the second argument
|
||||
is the string ``no series``. In SFM the first argument, the value,
|
||||
The equivalent template in GPM is::
|
||||
|
||||
``program: ifempty(field('series'), 'no series')``
|
||||
|
||||
The first argument to ``ifempty`` is the value of the field ``series``. The second argument
|
||||
is the string ``no series``. In SFM the first argument, the value of the field,
|
||||
is automatically passed (the invisible argument).
|
||||
|
||||
Several template functions, for example ``booksize()`` and ``current_library_name()``, take no arguments.
|
||||
@ -452,15 +455,15 @@ Because of the 'invisible argument' you cannot use these functions in SFM.
|
||||
Nested functions, where a function calls another function to compute an argument, cannot be used in SFM.
|
||||
For example this template, intended to return the first 5 characters of the series value uppercased, won't work in SFM::
|
||||
|
||||
{series:uppercase(substr(0,5))}
|
||||
``{series:uppercase(substr(0,5))}``
|
||||
|
||||
TPM and GPM support nested functions. The above template in TPM would be::
|
||||
|
||||
{series:'uppercase(substr($, 0,5))'}
|
||||
``{series:'uppercase(substr($, 0,5))'}``
|
||||
|
||||
In TPM it would be::
|
||||
In GPM it would be::
|
||||
|
||||
program: uppercase(substr(field('series'), 0,5))
|
||||
``program: uppercase(substr(field('series'), 0,5))``
|
||||
|
||||
|
||||
User-defined Python template functions
|
||||
|
Loading…
x
Reference in New Issue
Block a user