Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1from chameleon.loader import TemplateLoader as BaseLoader 

2from chameleon.zpt import template 

3 

4 

5class TemplateLoader(BaseLoader): 

6 formats = { 

7 "xml": template.PageTemplateFile, 

8 "text": template.PageTextTemplateFile, 

9 } 

10 

11 default_format = "xml" 

12 

13 def __init__(self, *args, **kwargs): 

14 formats = kwargs.pop('formats', None) 

15 if formats is not None: 

16 self.formats = formats 

17 

18 super(TemplateLoader, self).__init__(*args, **kwargs) 

19 

20 def load(self, filename, format=None): 

21 """Load and return a template file. 

22 

23 The format parameter determines will parse the file. Valid 

24 options are `xml` and `text`. 

25 """ 

26 

27 cls = self.formats[format or self.default_format] 

28 return super(TemplateLoader, self).load(filename, cls) 

29 

30 __getitem__ = load