Mercurial > p > roundup > code
changeset 7867:1774fdf2010a
doc: vale fixes, update TAL repeat object section.
For repeat object/variable, added back first() and last() methods now
that they are fixed. Moved start/end properties to separate property
table along with index.
Added details on how even works (e.g. even() is True when number() is
1 because the index is 0 which is even). Document returns from methods
are mostly truthy and not true.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 07 Apr 2024 20:58:58 -0400 |
| parents | 9bbc1d951677 |
| children | 6c219034bf31 |
| files | doc/reference.txt |
| diffstat | 1 files changed, 59 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/reference.txt Sun Apr 07 20:52:17 2024 -0400 +++ b/doc/reference.txt Sun Apr 07 20:58:58 2024 -0400 @@ -3342,12 +3342,12 @@ y_label, n_label, u_label (Boolean properties only) Set the labels for the true/false/undefined - states. If u_label is provided, it produces a + states. If u_label is defined, it produces a tri-state radio button selector. Otherwise, it allows selection of true,yes/false,no only. labelfirst (Boolean properties only) - place the labels before the radiobuttons + place the labels before the radio buttons rst only on String properties - render the value of the property as ReStructuredText (requires the :ref:`Docutils @@ -3355,7 +3355,7 @@ stext only on String properties - render the value of the property as StructuredText (requires the StructureText module to be - installed separately) (depricated, to be removed + installed separately) (deprecated, to be removed use rst or markdown instead). markdown only on String properties - render the value of the property as Markdown (requires a :ref:`Markdown module to be @@ -3396,15 +3396,17 @@ Will format as "2004-03-19" instead. - Interval properties - render the interval in a pretty - format (eg. "yesterday"). The format arguments are those used - in the standard ``strftime`` call (see the `Python Library + Interval properties - render the interval in a + pretty format (e.g. "yesterday"). The format + arguments are those used in the standard + ``strftime`` call (see the `Python Library Reference: time module`__) - Number properties - takes a printf style format argument - (default: '%0.3f') and formats the number accordingly. - If the value can't be converted, '' is returned if the - value is ``None`` otherwise it is converted to a string. + Number properties - takes a printf style format + argument (default: '%0.3f') and formats the number + accordingly. If the value can't be converted, '' + is returned if the value is ``None`` otherwise it + is converted to a string. popcal Generate a link to a popup calendar which may be used to edit the date field, for example:: @@ -3479,7 +3481,7 @@ __ https://docs.python.org/2/library/time.html -All of the above functions perform checks for permissions required to +All the above functions perform checks for permissions required to display or edit the data they are manipulating. The simplest case is editing an issue title. Including the expression:: @@ -3536,7 +3538,7 @@ sort index sort columns [(direction, column name)] =========== ============================================================ -There are several methods available on the request variable: +Several methods are available on the request variable: .. table:: :class: valign-top @@ -3544,7 +3546,7 @@ =============== ======================================================== Method Description =============== ======================================================== - base_javascript render some javascript that is used by other components + base_javascript render some javascript used by other components of the templating batch run the current index args through a filter and return a list of items (see `hyperdb item wrapper`_, and @@ -3582,11 +3584,12 @@ python:request.form['name'].value Note the "item" access used in the python case, and also note the -explicit "value" attribute we have to access. That's because the form -variables are stored as MiniFieldStorages. If there's more than one -"name" value in the form, then the above will break since -``request/form/name`` is actually a *list* of MiniFieldStorages. So it's -best to know beforehand what you're dealing with. +explicit "value" attribute we have to access. That's because the +form variables are stored as MiniFieldStorages. If there's more +than one "name" value in the form, then the above will break +since ``request/form/name`` is actually a *list* of +MiniFieldStorages. So it is best to know beforehand what you are +dealing with. The db variable @@ -3601,9 +3604,9 @@ db/user python:db.user -Also, the current id of the current user is available as -``db.getuid()``. This isn't so useful in templates (where you have -``request/user``), but it can be useful in detectors or interfaces. +Also, the id of the current user is available as +``db.getuid()``. This isn't as useful in templates (where you have +``request/user``), but is useful in detectors or interfaces. The access results in a `hyperdb class wrapper`_. @@ -3617,7 +3620,7 @@ This variable is used to access other templates in expressions and template macros. It doesn't have any useful methods defined. The -templates can be accessed using the following path expression:: +templates are accessed using the following path expression:: templates/name @@ -3638,14 +3641,15 @@ The repeat variable ~~~~~~~~~~~~~~~~~~~ -The repeat variable holds an entry for each active iteration. That is, if -you have a ``tal:repeat="user db/users"`` command, then there will be a -repeat variable entry called "user". This may be accessed as either:: - - repeat/user - python:repeat['user'] - -The "user" entry has a number of methods available for information: +The repeat variable holds an entry for each active iteration. If +you have a ``tal:repeat="myusers db/users"`` command, then there +will be a repeat variable entry called "myusers". This is accessed +as either:: + + repeat/myusers + python:repeat['myusers'] + +The "myusers" entry has nine methods available for information: .. table:: :class: valign-top @@ -3653,8 +3657,8 @@ =============== ========================================================= Method Description =============== ========================================================= - start True if the current item is the first in the sequence. - end True if the current item is the last in the sequence. + first True if the current item is the first in the sequence. + last True if the current item is the last in the sequence. even True if the current item is an even item in the sequence. odd True if the current item is an odd item in the sequence. number Current position in the sequence, starting from 1. @@ -3666,6 +3670,24 @@ Roman Same as roman(), except uppercase. =============== ========================================================= +(Note: except for even, True above can be a truthy/falsy value not +actually True/False. Also the first item in a sequence is 0, +so it starts with even() = True when number() returns 1 as index +is 0.) + +It also has the following properties: + +.. table:: + :class: valign-top + + =============== ========================================================= + Properties Description + =============== ========================================================= + end Truthy if the current item is the last in the sequence. + index Current index in sequence starting at 0 + start Truthy if the current item is the first in the sequence. + =============== ========================================================= + For example, this will print a comma after each element except the last:: @@ -3673,11 +3695,15 @@ <tal:x tal:repeat="field python:request.form['properties'].value.split(',')"> <tal:x tal:replace="field"></tal:x> - <tal:x tal:condition="python:not repeat['field'].end" + <tal:x tal:condition="python:not repeat['field'].last()" tal:content="string:,"></tal:x> </tal:x> </span> +The same can be done using a path expression:: + + <tal:x tal:condition="not: repeat/field/last" ... + .. _templating utilities: The utils variable
