summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e01a963)
raw | patch | inline | side by side (parent: e01a963)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Tue, 20 Aug 2002 08:09:36 +0000 (08:09 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Tue, 20 Aug 2002 08:09:36 +0000 (08:09 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@977 57a73879-2fb5-44c3-a270-3262357dd7e2
doc/templating.txt | patch | blob | history |
diff --git a/doc/templating.txt b/doc/templating.txt
index 8a336b5fc32850b8155867fde65c0e016551fd57..b5bf93e844cf724d681928af1349bfde10bda555 100644 (file)
--- a/doc/templating.txt
+++ b/doc/templating.txt
HTML Templating Mechanisms
==========================
-:Version: $Revision: 1.6 $
+:Version: $Revision: 1.7 $
Current Situation and Issues
============================
</tr>
</table>
+PageTemplates in a Nutshell
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+PageTemplates consist of three technologies:
+
+TAL - Template Attribute Language
+ This is the syntax which is woven into the HTML using the ``tal:`` tag
+ attributes. A TAL parser pulls out the TAL commands from the attributes
+ runs them using some expression engine.
+
+TALES - TAL Expression Language
+ The expression engine used in this case is TALES, which runs the expressions
+ that form the tag attribute values. TALES expressions come in three
+ flavours:
+
+ Path Expressions - eg. ``foo/bar/frozz``
+ These are object attribute / item accesses. Roughly speaking, the path
+ ``foo/bar/frozz`` is broken into parts ``foo``, ``bar`` and ``frozz``. The
+ ``foo`` part is the root of the expression. We then look for a ``bar``
+ attribute on foo, or failing that, a bar item (as in foo['bar']). If that
+ fails, the path expression fails. When we get to the end, the object we're
+ left with is evaluated to get a string - methods are called, objects are
+ stringified. Path expressions may have an optional ``path:`` prefix, though
+ they are the default expression type, so it's not necessary.
+
+ String Expressions - eg. ``string:hello ${user/name}``
+ These expressions are simple string interpolations (though they can be just
+ plain strings with no interpolation if you want. The expression in the
+ ``${ ... }`` is just a path expression as above.
+
+ Python Expressions - eg. ``python: 1+1``
+ These expressions give the full power of Python. All the "root level"
+ variables are available, so ``python:foo.bar.frozz()`` might be equivalent
+ to ``foo/bar/frozz``, assuming that ``frozz`` is a method.
+
+PageTemplates
+ The PageTemplates module glues together TAL and TALES.
+
Implementation
~~~~~~~~~~~~~~
I'm envisaging an infrastructure layer where each template has the following
-variables defined:
+"root level" (that is, driectly accessible in the TALES namespace) variables
+defined:
+*user*
+ the current user node as an HTMLItem instance
*class*
- the current class of node being displayed
+ the current class of node being displayed as an HTMLClass instance
*item*
- the current node from the database, if we're viewing a specific node
+ the current node from the database, if we're viewing a specific node, as an
+ HTMLItem instance
(*classname*)
the current node is also available under its classname, so a *user* node
- would also be available under the name *user*.
+ would also be available under the name *user*. This is also an HTMLItem
+ instance.
*form*
- the current CGI form information
+ the current CGI form information as a mapping of form argument name to value
*instance*
the current instance
*db*
the current instance config
*util*
utility methods
+*modules*
+ Python modules made available (XXX: not sure what's actually in there tho)
Accesses through a class (either through *class* or *db.<classname>*):