-
Notifications
You must be signed in to change notification settings - Fork 2
/
useTemplate.py
executable file
·35 lines (29 loc) · 1.27 KB
/
useTemplate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/python
# *
# * C Template Library 1.0
# *
# * Copyright 2009 Stephen C. Losen. Distributed under the terms
# * of the GNU General Public License (GPL)
# *
# * Python port written by Marek Lipert ([email protected])
# *
# *
import _ctemplate
d = {"varName":"haha1",
"aLoop":[{"loopVar":"loopVal 1","loopVar2":"kokoszka"},{"loopVar":"loopVal 2","loopVar2":"kogut"} ],
"sweet":{"name":"Prince Polo",
"price":"5.50","isBig":"0"
}
}
print _ctemplate.compile_template("""<* This is a comment *>
varName: <TMPL_var name="varName">
<TMPL_loop name="aLoop">
Loop has var <TMPL_var name="loopVar"> a pieje nam <TMPL_var name="loopVar2">
Loops can be nested!
</TMPL_loop>
Sweet name: <TMPL_var name="sweet.name">
Sweet price: <TMPL_var name="sweet.price">
<TMPL_if name="sweet.isBig" value="1">
Sweet is big
</TMPL_IF>
""",d)