added parsing code for "for item in seq recursive" and improved parser interface a bit

--HG--
branch : trunk
diff --git a/docs/cache_extension.py b/docs/cache_extension.py
index 9f324d2..ec0067b 100644
--- a/docs/cache_extension.py
+++ b/docs/cache_extension.py
@@ -27,7 +27,7 @@
 
         # if there is a comma, the user provided a timeout.  If not use
         # None as second parameter.
-        if parser.skip_comma():
+        if parser.stream.skip_if('comma'):
             args.append(parser.parse_expression())
         else:
             args.append(nodes.Const(None))
diff --git a/docs/extensions.rst b/docs/extensions.rst
index f5527f7..63e9cd9 100644
--- a/docs/extensions.rst
+++ b/docs/extensions.rst
@@ -155,7 +155,7 @@
 
 .. autoclass:: jinja2.parser.Parser
     :members: parse_expression, parse_tuple, parse_assign_target,
-              parse_statements, skip_colon, skip_comma, free_identifier
+              parse_statements, free_identifier
 
     .. attribute:: filename
 
@@ -169,7 +169,7 @@
         The current :class:`~jinja2.lexer.TokenStream`
 
 .. autoclass:: jinja2.lexer.TokenStream
-   :members: push, look, eos, skip, next, expect
+   :members: push, look, eos, skip, next, next_if, skip_if, expect
 
    .. attribute:: current
 
diff --git a/docs/index.rst b/docs/index.rst
index 308563a..43f3680 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -15,6 +15,7 @@
    extensions
    integration
    switching
+   tricks
 
    changelog
 
diff --git a/docs/templates.rst b/docs/templates.rst
index d7a0f91..ea19e2d 100644
--- a/docs/templates.rst
+++ b/docs/templates.rst
@@ -281,7 +281,8 @@
 this template "extends" another template.  When the template system evaluates
 this template, first it locates the parent.  The extends tag should be the
 first tag in the template.  Everything before it is printed out normally and
-may cause confusion.
+may cause confusion.  For details about this behavior and how to take
+advantage of it, see :ref:`null-master-fallback`.
 
 The filename of the template depends on the template loader.  For example the
 :class:`FileSystemLoader` allows you to access other templates by giving the
diff --git a/docs/tricks.rst b/docs/tricks.rst
new file mode 100644
index 0000000..6029ec5
--- /dev/null
+++ b/docs/tricks.rst
@@ -0,0 +1,81 @@
+Tipps and Tricks
+================
+
+.. highlight:: html+jinja
+
+This part of the documentation shows some tipps and tricks for Jinja2
+templates.
+
+
+.. _null-master-fallback:
+
+Null-Master Fallback
+--------------------
+
+Jinja2 supports dynamic inheritance and does not distinguish between parent
+and child template as long as no `extends` tag is visited.  While this leads
+to the surprising behavior that everything before the first `extends` tag
+including whitespace is printed out instead of being igored, it can be used
+for a neat trick.
+
+Usually child templates extend from one template that adds a basic HTML
+skeleton.  However it's possible put the `extends` tag into an `if` tag to
+only extend from the layout template if the `standalone` variable evaluates
+to false which it does per default if it's not defined.  Additionally a very
+basic skeleton is added to the file so that if it's indeed rendered with
+`standalone` set to `True` a very basic HTML skeleton is added::
+
+    {% if not standalone %}{% extends 'master.html' %}{% endif -%}
+    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+    <title>{% block title %}The Page Title{% endblock %}</title>
+    <link rel="stylesheet" href="style.css" type="text/css">
+    {% block body %}
+      <p>This is the page body.</p>
+    {% endblock %}
+
+
+Alternating Rows
+----------------
+
+If you want to have different styles for each row of a table or
+list you can use the `cycle` method on the `loop` object::
+
+    <ul>
+    {% for row in rows %}
+      <li class="{{ loop.cycle('odd', 'even') }}">{{ row }}</li>
+    {% endfor %}
+    </ul>
+
+`cycle` can take an unlimited amount of strings.  Each time this
+tag is encountered the next item from the list is rendered.
+
+
+Highlighting Active Menu Items
+------------------------------
+
+Often you want to have a navigation bar with an active navigation
+item.  This is really simple to achieve.  Because assignments outside
+of `block`\s in child templates are global and executed before the layout
+template is evaluated it's possible to define the active menu item in the
+child template::
+
+    {% extends "layout.html" %}
+    {% set active_page = "index" %}
+
+The layout template can then access `active_page`.  Additionally it makes
+sense to defined a default for that variable::
+
+    {% navigation_bar = [
+        ('/', 'index', 'Index'),
+        ('/downloads/', 'downloads', 'Downloads'),
+        ('/about/', 'about', 'About')
+    ] -%}
+    {% active_page = active_page|default('index') -%}
+    ...
+    <ul id="navigation">
+    {% for href, id, caption in navigation_bar %}
+      <li{% if id == active_page %} class="active"{% endif
+      %}><a href="{{ href|e }}">{{ caption|e }}</a>/li>
+    {% endfor %}
+    </ul>
+    ...