Package spade :: Module pyratemp :: Class FileLoader
[hide private]
[frames] | no frames]

Class FileLoader

source code

Load template from a file.

When loading a template from a file, it's possible to including other templates (by using 'include' in the template). But for simplicity and security, all included templates have to be in the same directory! (see 'allowed_path')

Instance Methods [hide private]
 
__init__(self, allowed_path, encoding='utf-8')
Init the loader.
source code
 
load(self, filename)
Load a template from a file.
source code
Method Details [hide private]

__init__(self, allowed_path, encoding='utf-8')
(Constructor)

source code 

Init the loader.

:Parameters:

  • allowed_path: path of the template-files
  • encoding: encoding of the template-files

load(self, filename)

source code 
Load a template from a file.

Check if filename is allowed and return its contens in unicode.
:Parameters:
    - filename: filename of the template without path
:Returns:
    the contents of the template-file in unicode