Package qm :: Package external :: Package DocumentTemplate :: Module DTtestExpr
[hide private]
[frames] | no frames]

Source Code for Module qm.external.DocumentTemplate.DTtestExpr

 1  ############################################################################## 
 2  # 
 3  # Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved. 
 4  # 
 5  # This software is subject to the provisions of the Zope Public License, 
 6  # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution. 
 7  # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED 
 8  # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
 9  # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS 
10  # FOR A PARTICULAR PURPOSE 
11  # 
12  ############################################################################## 
13  __doc__='''short description 
14   
15   
16  $Id: DTtestExpr.py 1069 2008-11-13 21:55:43Z stefan $''' 
17  __version__='$Revision: 1069 $'[11:-2] 
18   
19  from DocumentTemplate import * 
20  import sys 
21   
22 -def test1():
23 print HTML('area code=<!--#var expr="phone[:3]"-->')(phone='7035551212')
24
25 -def test2():
26 print HTML('area code=<!--#var expr="phone.number"-->')(phone='7035551212')
27
28 -def test3():
29 print HTML('area code=<!--#var expr="phone*1000"-->')(phone='7035551212')
30
31 -def test4():
32 33 h=HTML( 34 """ 35 <!--#if expr="level==1"--> 36 level was 1 37 <!--#elif expr="level==2"--> 38 level was 2 39 <!--#elif expr="level==3"--> 40 level was 3 41 <!--#else--> 42 level was something else 43 <!--#endif--> 44 """) 45 46 for i in range(4): 47 print '-' * 77 48 print i, h(level=i) 49 print '-' * 77
50 51 52 if __name__ == "__main__": 53 try: command=sys.argv[1] 54 except: command='main' 55 globals()[command]() 56