@@ -3342,20 +3342,20 @@ There are several methods available on these wrapper objects:
33423342
33433343 y_label, n_label, u_label (Boolean properties only)
33443344 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
33463346 tri-state radio button selector. Otherwise, it
33473347 allows selection of true,yes/false,no only.
33483348
33493349 labelfirst (Boolean properties only)
3350- place the labels before the radiobuttons
3350+ place the labels before the radio buttons
33513351
33523352 rst only on String properties - render the value of the property
33533353 as ReStructuredText (requires the :ref:`Docutils
33543354 module to be installed separately<install/docutils>`).
33553355
33563356 stext only on String properties - render the value of the property
33573357 as StructuredText (requires the StructureText module to be
3358- installed separately) (depricated , to be removed
3358+ installed separately) (deprecated , to be removed
33593359 use rst or markdown instead).
33603360 markdown only on String properties - render the value of the property
33613361 as Markdown (requires a :ref:`Markdown module to be
@@ -3396,15 +3396,17 @@ There are several methods available on these wrapper objects:
33963396
33973397 Will format as "2004-03-19" instead.
33983398
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
34023403 Reference: time module`__)
34033404
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.
34083410
34093411 popcal Generate a link to a popup calendar which may be used to
34103412 edit the date field, for example::
@@ -3479,7 +3481,7 @@ There are several methods available on these wrapper objects:
34793481
34803482__ https://docs.python.org/2/library/time.html
34813483
3482- All of the above functions perform checks for permissions required to
3484+ All the above functions perform checks for permissions required to
34833485display or edit the data they are manipulating. The simplest case is
34843486editing an issue title. Including the expression::
34853487
@@ -3536,15 +3538,15 @@ request.
35363538 sort index sort columns [(direction, column name)]
35373539 =========== ============================================================
35383540
3539- There are several methods available on the request variable:
3541+ Several methods are available on the request variable:
35403542
35413543.. table::
35423544 :class: valign-top
35433545
35443546 =============== ========================================================
35453547 Method Description
35463548 =============== ========================================================
3547- base_javascript render some javascript that is used by other components
3549+ base_javascript render some javascript used by other components
35483550 of the templating
35493551 batch run the current index args through a filter and return a
35503552 list of items (see `hyperdb item wrapper`_, and
@@ -3582,11 +3584,12 @@ or the python expression::
35823584 python:request.form['name'].value
35833585
35843586Note 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.
35903593
35913594
35923595The db variable
@@ -3601,9 +3604,9 @@ you want access to the "user" class, for example, you would use::
36013604 db/user
36023605 python:db.user
36033606
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.
36073610
36083611The access results in a `hyperdb class wrapper`_.
36093612
@@ -3617,7 +3620,7 @@ template engine loader class.
36173620
36183621This variable is used to access other templates in expressions and
36193622template 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::
36213624
36223625 templates/name
36233626
@@ -3638,23 +3641,24 @@ or the python expression::
36383641The repeat variable
36393642~~~~~~~~~~~~~~~~~~~
36403643
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::
36443648
3645- repeat/user
3646- python:repeat['user ']
3649+ repeat/myusers
3650+ python:repeat['myusers ']
36473651
3648- The "user " entry has a number of methods available for information:
3652+ The "myusers " entry has nine methods available for information:
36493653
36503654.. table::
36513655 :class: valign-top
36523656
36533657 =============== =========================================================
36543658 Method Description
36553659 =============== =========================================================
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.
36583662 even True if the current item is an even item in the sequence.
36593663 odd True if the current item is an odd item in the sequence.
36603664 number Current position in the sequence, starting from 1.
@@ -3666,18 +3670,40 @@ The "user" entry has a number of methods available for information:
36663670 Roman Same as roman(), except uppercase.
36673671 =============== =========================================================
36683672
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+
36693691For example, this will print a comma after each element except the
36703692last::
36713693
36723694 <span>
36733695 <tal:x tal:repeat="field
36743696 python:request.form['properties'].value.split(',')">
36753697 <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() "
36773699 tal:content="string:,"></tal:x>
36783700 </tal:x>
36793701 </span>
36803702
3703+ The same can be done using a path expression::
3704+
3705+ <tal:x tal:condition="not: repeat/field/last" ...
3706+
36813707.. _templating utilities:
36823708
36833709The utils variable
0 commit comments