Changes between Version 1 and Version 2 of WorkInProgress/PluggableDirectivesLibraries/TextTemplates
- Timestamp:
- Jun 11, 2010, 9:11:09 PM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
WorkInProgress/PluggableDirectivesLibraries/TextTemplates
v1 v2 18 18 embedding Python code in templates. 19 19 20 .. note:: Actually, Genshi currently has two different syntaxes for text21 templates languages: One implemented by the class ``OldTextTemplate``22 and another implemented by ``NewTextTemplate``. This documentation23 concentrates on the latter, which is planned to completely replace the24 older syntax. The older syntax is briefly described under legacy_.25 26 20 .. _django: http://www.djangoproject.com/ 27 21 … … 47 41 effectively treated as a comment. 48 42 43 An exception to that rule is the {% namespace %} directive. 44 Namespace declarations are considered one line statements that will enhance 45 text templates by provision of additional directives defined in so-called 46 directive libraries. 47 49 48 If you want to include a literal delimiter in the output, you need to escape it 50 49 by prepending a backslash character (``\``). 50 51 .. Note: Directives libraries are similar to JSP tag libraries and are a new feature 52 of Genshi. 53 54 55 Namespaces 56 ========== 57 58 .. _`namespace`: 59 60 ``{% namespace %}`` 61 ------------------- 62 63 Declares a new namespace for use with Genshi directives. Individual directives 64 being used in the template will have to be prefixed by the namespace alias 65 defined as part of the namespace declaration. 66 67 The default namespace is "http://genshi.edgewall.org/". All non prefixed 68 directives will be looked up from that namespace. If a prefix was defined, 69 and there is also a valid namespace declaration for it, then that namespace 70 will be used instead for looking up the directive. 71 72 .. code-block:: genshitext 73 74 {% namespace "http://genshi.edgewall.org/" %} 75 {% namespace py "http://genshi.edgewall.org/" %} 76 {% namespace foo "http://foo.example.org/" %} 77 78 # use if directive from default namespace 79 80 {% if ... %} 81 82 # use bar directive from foo namespace 83 84 {% foo:bar ... %} 85 86 # use if directive (from default namespace) 87 88 {% py:if ... %} 89 90 More information on directives libraries can be found 91 under `Pluggable Directives Libraries <directives_libraries.html>`_. 92 51 93 52 94