summaryrefslogtreecommitdiff
path: root/docs/users_guide_2_src/eg_3.py
blob: 5c89a65dd67f7e9066d0dee942801e922dd9b1f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from Cheetah.Template import Template

#The namespaces list is a list of dictionaries and/or 
#class instances. Search is for dictionary key or object
#attributes in this list
class X:
    pass


x = X()
x.value3 = 3
x.value4 = 4

tmpl = "$value1, $value2, $value3, $value4"
NS = [{'value1':1},{'value2':2}, x]

t = Template.compile(source=tmpl)(namespaces=NS)
print t.respond() #1,2,3,4