From 38055729c834fc3253158d73f162b83c51239e3d Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Sun, 18 Oct 2020 12:27:31 +0100 Subject: [PATCH] Fix bug 1900316: Rewrite example in documentation for translations. --- manual/template_lang.rst | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/manual/template_lang.rst b/manual/template_lang.rst index 18e1604c0e..725e08ac58 100644 --- a/manual/template_lang.rst +++ b/manual/template_lang.rst @@ -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 equivalent template in GPM is:: -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, + ``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