Commit 9d57e3e8 authored by Amos Latteier's avatar Amos Latteier

progress on tales reference.

parent 55a6f28e
TALES Exists expressions
Syntax
Exists expression syntax::
exists_expressions ::= 'exists:' path_expression
Description
Exists expressions test for the existence of paths. An exists
expression returns true when the path expressions following it
expression returns a value. It is false when the path expression
cannot locate an object.
Examples
Testing for the existence of a form variable::
<p tal:condition="not:exists:request/form/number">
Please enter a number between 0 and 5
</p>
Note that in this case you can't use the expression,
"not:request/form/number", since that expression will be true if
the 'number' variable exists and is zero.
\ No newline at end of file
TALES No call expressions TALES No-call expressions
Syntax Syntax
XXX No-call expression syntax::
nocall_expression ::= 'no-call:' expression
Description Description
XXX No-call expressions avoid rendering the results of another
\ No newline at end of file expression.
An ordinary path expression tries to render the object that it
fetches. This means that if the object is a function, Script,
Method, or some other kind of executable thing, then expression
will evaluate to the result of calling the object. This is
usually what you want, but not always. For example, if you want
to put a DTML Document into a variable so that you can refer to
its properties, you can't use a normal path expression because it
will render the Document into a string.
Examples
Using no-call to get the properties of a document::
<span tal:define="doc nocall:here/aDoc"
tal:content="string:${doc/getId}: ${doc/title}">
Id: Title</span>
Using no-call expressions on a functions::
<p tal:define="join nocall:modules/string/join">
This example defines a variable 'join' which is bound to the
'string.join' function.
...@@ -2,7 +2,9 @@ TALES Not expressions ...@@ -2,7 +2,9 @@ TALES Not expressions
Syntax Syntax
XXX Not expression syntax::
not_expression ::= 'not:' expression
Description Description
...@@ -28,3 +30,11 @@ TALES Not expressions ...@@ -28,3 +30,11 @@ TALES Not expressions
Zope considers all objects not specifically listed above as Zope considers all objects not specifically listed above as
*false* (including negative numbers) to be *true*. *false* (including negative numbers) to be *true*.
Examples
Testing a sequence::
<p tal:condition="not:here/objectIds">
There are no contained objects.
</p>
...@@ -4,9 +4,9 @@ TALES Path expressions ...@@ -4,9 +4,9 @@ TALES Path expressions
Path expression syntax:: Path expression syntax::
PathExpr ::= Path [ '|' Path ]* PathExpr ::= Path [ '|' Path ]*
Path ::= variable [ '/' URL_Segment ]* Path ::= variable [ '/' URL_Segment ]*
variable ::= Name variable ::= Name
Description Description
...@@ -55,7 +55,17 @@ TALES Path expressions ...@@ -55,7 +55,17 @@ TALES Path expressions
Examples Examples
XXX Inserting a cookie variable or a property::
<span tal:replace="request/cookies/pref | here/pref">
preference
</span>
Inserting the user name::
<p tal:content="user/getUserName">
User name
</p>
......
...@@ -36,7 +36,9 @@ TALES Overview ...@@ -36,7 +36,9 @@ TALES Overview
These are the TALES expression types supported by Zope: These are the TALES expression types supported by Zope:
* "no-call":tales-no-call.stx expression - don't call a value * "exists":tales-exists.stx expressions - test existence of a value
* "no-call":tales-no-call.stx expressions - don't call a value
* "not:tales-not.stx expressions - negate a value * "not:tales-not.stx expressions - negate a value
...@@ -49,41 +51,48 @@ TALES Overview ...@@ -49,41 +51,48 @@ TALES Overview
Built-in Names Built-in Names
These are the names that are built-in the TALES in Zope: These are the names that are built-in the TALES in Zope:
- *nothing* - special singleton value used by TAL to represent - *nothing* - special singleton value used by TAL to represent
a *non-value* (e.g. void, None, Nil, NULL). a *non-value* (e.g. void, None, Nil, NULL).
- *default* - special singleton value used by TAL to specify that - *default* - special singleton value used by TAL to specify that
existing text should not be replaced. existing text should not be replaced. See the documentation for
individual TAL statements for details on how they interpret
*default*.
- *options* - the *keyword* arguments passed to the template. - *options* - the *keyword* arguments passed to the template. These
are generally available when a template is called from Python,
rather than from the web.
- *repeat* - the 'repeat' variables (see RepeatVariable). - *repeat* - the 'repeat' variables see the
"tal:repeat":tal-repeat.stx documentation.
- *attrs* - a dictionary containing the initial values of the - *attrs* - a dictionary containing the initial values of the
attributes of the current statement tag. attributes of the current statement tag.
- *CONTEXTS* - the list of standard names (this list). This can be - *CONTEXTS* - the list of standard names (this list). This can be
used to access a builtin variable that has been hidden by a local used to access a builtin variable that has been hidden by a local
or global variable with the same name. or global variable with the same name.
- *root* - the system's top-most object. - *root* - the system's top-most object. In Zope this corresponds
to the root folder.
- *here* - the object to which the template is being applied. - *here* - the object to which the template is being applied.
- *container* - the template's container object. - *container* - the template's container object. In Zope this is
the folder in which the template is located.
- *template* - the template itself. - *template* - the template itself.
- *request* - the publishing request object. - *request* - the publishing request object.
- *user* - the authenticated user object. - *user* - the authenticated user object.
- *modules* - a collection through which all Python modules and - *modules* - a collection through which all Python modules and
packages can be accessed. Some or many of these may not be packages can be accessed. Some or many of these may not be
usable in TALES, however, depending on the security policies usable in TALES, however, depending on the security policies
of the template's implementation. of the template's implementation.
Note the names 'root', 'here', 'container', 'template', 'request', Note the names 'root', 'here', 'container', 'template', 'request',
'user', and 'modules' are optional names supported by Zope, but 'user', and 'modules' are optional names supported by Zope, but
...@@ -93,7 +102,9 @@ TALES Overview ...@@ -93,7 +102,9 @@ TALES Overview
"TAL overview":tal.stx "TAL overview":tal.stx
"no-call":tales-no-call.stx expression "exists":tales-exists.stx expressions
"no-call":tales-no-call.stx expressions
"not:tales-not.stx expressions "not:tales-not.stx expressions
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment