@@ -3342,20 +3342,20 @@ There are several methods available on these wrapper objects:
3342
3342
3343
3343
y_label, n_label, u_label (Boolean properties only)
3344
3344
Set the labels for the true/false/undefined
3345
- states. If u_label is provided , it produces a
3345
+ states. If u_label is defined , it produces a
3346
3346
tri-state radio button selector. Otherwise, it
3347
3347
allows selection of true,yes/false,no only.
3348
3348
3349
3349
labelfirst (Boolean properties only)
3350
- place the labels before the radiobuttons
3350
+ place the labels before the radio buttons
3351
3351
3352
3352
rst only on String properties - render the value of the property
3353
3353
as ReStructuredText (requires the :ref:`Docutils
3354
3354
module to be installed separately<install/docutils>`).
3355
3355
3356
3356
stext only on String properties - render the value of the property
3357
3357
as StructuredText (requires the StructureText module to be
3358
- installed separately) (depricated , to be removed
3358
+ installed separately) (deprecated , to be removed
3359
3359
use rst or markdown instead).
3360
3360
markdown only on String properties - render the value of the property
3361
3361
as Markdown (requires a :ref:`Markdown module to be
@@ -3396,15 +3396,17 @@ There are several methods available on these wrapper objects:
3396
3396
3397
3397
Will format as "2004-03-19" instead.
3398
3398
3399
- Interval properties - render the interval in a pretty
3400
- format (eg. "yesterday"). The format arguments are those used
3401
- in the standard ``strftime`` call (see the `Python Library
3399
+ Interval properties - render the interval in a
3400
+ pretty format (e.g. "yesterday"). The format
3401
+ arguments are those used in the standard
3402
+ ``strftime`` call (see the `Python Library
3402
3403
Reference: time module`__)
3403
3404
3404
- Number properties - takes a printf style format argument
3405
- (default: '%0.3f') and formats the number accordingly.
3406
- If the value can't be converted, '' is returned if the
3407
- value is ``None`` otherwise it is converted to a string.
3405
+ Number properties - takes a printf style format
3406
+ argument (default: '%0.3f') and formats the number
3407
+ accordingly. If the value can't be converted, ''
3408
+ is returned if the value is ``None`` otherwise it
3409
+ is converted to a string.
3408
3410
3409
3411
popcal Generate a link to a popup calendar which may be used to
3410
3412
edit the date field, for example::
@@ -3479,7 +3481,7 @@ There are several methods available on these wrapper objects:
3479
3481
3480
3482
__ https://docs.python.org/2/library/time.html
3481
3483
3482
- All of the above functions perform checks for permissions required to
3484
+ All the above functions perform checks for permissions required to
3483
3485
display or edit the data they are manipulating. The simplest case is
3484
3486
editing an issue title. Including the expression::
3485
3487
@@ -3536,15 +3538,15 @@ request.
3536
3538
sort index sort columns [(direction, column name)]
3537
3539
=========== ============================================================
3538
3540
3539
- There are several methods available on the request variable:
3541
+ Several methods are available on the request variable:
3540
3542
3541
3543
.. table::
3542
3544
:class: valign-top
3543
3545
3544
3546
=============== ========================================================
3545
3547
Method Description
3546
3548
=============== ========================================================
3547
- base_javascript render some javascript that is used by other components
3549
+ base_javascript render some javascript used by other components
3548
3550
of the templating
3549
3551
batch run the current index args through a filter and return a
3550
3552
list of items (see `hyperdb item wrapper`_, and
@@ -3582,11 +3584,12 @@ or the python expression::
3582
3584
python:request.form['name'].value
3583
3585
3584
3586
Note the "item" access used in the python case, and also note the
3585
- explicit "value" attribute we have to access. That's because the form
3586
- variables are stored as MiniFieldStorages. If there's more than one
3587
- "name" value in the form, then the above will break since
3588
- ``request/form/name`` is actually a *list* of MiniFieldStorages. So it's
3589
- best to know beforehand what you're dealing with.
3587
+ explicit "value" attribute we have to access. That's because the
3588
+ form variables are stored as MiniFieldStorages. If there's more
3589
+ than one "name" value in the form, then the above will break
3590
+ since ``request/form/name`` is actually a *list* of
3591
+ MiniFieldStorages. So it is best to know beforehand what you are
3592
+ dealing with.
3590
3593
3591
3594
3592
3595
The db variable
@@ -3601,9 +3604,9 @@ you want access to the "user" class, for example, you would use::
3601
3604
db/user
3602
3605
python:db.user
3603
3606
3604
- Also, the current id of the current user is available as
3605
- ``db.getuid()``. This isn't so useful in templates (where you have
3606
- ``request/user``), but it can be useful in detectors or interfaces.
3607
+ Also, the id of the current user is available as
3608
+ ``db.getuid()``. This isn't as useful in templates (where you have
3609
+ ``request/user``), but is useful in detectors or interfaces.
3607
3610
3608
3611
The access results in a `hyperdb class wrapper`_.
3609
3612
@@ -3617,7 +3620,7 @@ template engine loader class.
3617
3620
3618
3621
This variable is used to access other templates in expressions and
3619
3622
template macros. It doesn't have any useful methods defined. The
3620
- templates can be accessed using the following path expression::
3623
+ templates are accessed using the following path expression::
3621
3624
3622
3625
templates/name
3623
3626
@@ -3638,23 +3641,24 @@ or the python expression::
3638
3641
The repeat variable
3639
3642
~~~~~~~~~~~~~~~~~~~
3640
3643
3641
- The repeat variable holds an entry for each active iteration. That is, if
3642
- you have a ``tal:repeat="user db/users"`` command, then there will be a
3643
- repeat variable entry called "user". This may be accessed as either::
3644
+ The repeat variable holds an entry for each active iteration. If
3645
+ you have a ``tal:repeat="myusers db/users"`` command, then there
3646
+ will be a repeat variable entry called "myusers". This is accessed
3647
+ as either::
3644
3648
3645
- repeat/user
3646
- python:repeat['user ']
3649
+ repeat/myusers
3650
+ python:repeat['myusers ']
3647
3651
3648
- The "user " entry has a number of methods available for information:
3652
+ The "myusers " entry has nine methods available for information:
3649
3653
3650
3654
.. table::
3651
3655
:class: valign-top
3652
3656
3653
3657
=============== =========================================================
3654
3658
Method Description
3655
3659
=============== =========================================================
3656
- start True if the current item is the first in the sequence.
3657
- end True if the current item is the last in the sequence.
3660
+ first True if the current item is the first in the sequence.
3661
+ last True if the current item is the last in the sequence.
3658
3662
even True if the current item is an even item in the sequence.
3659
3663
odd True if the current item is an odd item in the sequence.
3660
3664
number Current position in the sequence, starting from 1.
@@ -3666,18 +3670,40 @@ The "user" entry has a number of methods available for information:
3666
3670
Roman Same as roman(), except uppercase.
3667
3671
=============== =========================================================
3668
3672
3673
+ (Note: except for even, True above can be a truthy/falsy value not
3674
+ actually True/False. Also the first item in a sequence is 0,
3675
+ so it starts with even() = True when number() returns 1 as index
3676
+ is 0.)
3677
+
3678
+ It also has the following properties:
3679
+
3680
+ .. table::
3681
+ :class: valign-top
3682
+
3683
+ =============== =========================================================
3684
+ Properties Description
3685
+ =============== =========================================================
3686
+ end Truthy if the current item is the last in the sequence.
3687
+ index Current index in sequence starting at 0
3688
+ start Truthy if the current item is the first in the sequence.
3689
+ =============== =========================================================
3690
+
3669
3691
For example, this will print a comma after each element except the
3670
3692
last::
3671
3693
3672
3694
<span>
3673
3695
<tal:x tal:repeat="field
3674
3696
python:request.form['properties'].value.split(',')">
3675
3697
<tal:x tal:replace="field"></tal:x>
3676
- <tal:x tal:condition="python:not repeat['field'].end "
3698
+ <tal:x tal:condition="python:not repeat['field'].last() "
3677
3699
tal:content="string:,"></tal:x>
3678
3700
</tal:x>
3679
3701
</span>
3680
3702
3703
+ The same can be done using a path expression::
3704
+
3705
+ <tal:x tal:condition="not: repeat/field/last" ...
3706
+
3681
3707
.. _templating utilities:
3682
3708
3683
3709
The utils variable
0 commit comments