Changeset 5351:c8084839327f in livinglogic.python.xist

Show
Ignore:
Timestamp:
02/16/13 14:03:06 (7 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

<?return?> tags in UL4 templates simply end the template rendering.

Files:
3 modified

Legend:

Unmodified
Added
Removed
  • docs/UL4.rst

    r5343 r5351  
    13001300When no ``<?return?>`` tag is encountered, ``None`` will be returned. 
    13011301 
     1302When a ``<?return?>`` tag is encountered when the template is used as a template, 
     1303output will simply stop. 
     1304 
    13021305 
    13031306Delimiters 
  • src/ll/ul4c.py

    r5349 r5351  
    21682168        template code. 
    21692169        """ 
    2170         yield from super().eval(vars) # Bypass ``self.eval()`` which simply stores the object as a local variable 
     2170        try: 
     2171            yield from super().eval(vars) # Bypass ``self.eval()`` which simply stores the object as a local variable 
     2172        except ReturnException: 
     2173            pass 
    21712174 
    21722175    def renders(self, **vars): 
  • test/test_ul4.py

    r5343 r5351  
    33023302 
    33033303@pytest.mark.ul4 
     3304def test_return_in_template(r): 
     3305    assert "gurk" == r("gurk<?return 42?>hurz") 
     3306 
     3307 
     3308@pytest.mark.ul4 
    33043309def test_jssource(): 
    33053310    t = universaltemplate()