Révision c87f87c1
Ajouté par Jérôme Schneider il y a plus de 9 ans
mandaye/global_config.py | ||
---|---|---|
61 | 61 |
|
62 | 62 |
# Template directory |
63 | 63 |
template_directory = os.path.join(_PROJECT_PATH, 'mandaye/templates') |
64 |
templates_directories = [] |
|
64 | 65 |
# Configuration directory |
65 | 66 |
config_root = os.path.join(_PROJECT_PATH, 'conf.d') |
66 | 67 |
# Static path |
mandaye/skel/example.module/config.py | ||
---|---|---|
87 | 87 |
## PATH |
88 | 88 |
# Configuration directory |
89 | 89 |
config_root = config.get('dirs', 'config_root') |
90 |
# Template directory |
|
91 |
template_directory = os.path.join(BASE_DIR, 'templates') |
|
90 |
# Templates directories |
|
91 |
templates_directories = [os.path.join(BASE_DIR, 'templates')] |
|
92 |
if config.get('dirs', 'templates_directories'): |
|
93 |
templates_directories.extend(config.get('dirs', 'templates_directories').split(' ')) |
|
92 | 94 |
# Static url |
93 | 95 |
static_url = config.get('dirs', 'static_url') |
94 | 96 |
# Static folder |
mandaye/skel/example.module/default-config.ini | ||
---|---|---|
10 | 10 |
data_dir: %(base_dir)s/data |
11 | 11 |
static_root: %(base_dir)s/{project_name}/static |
12 | 12 |
static_url: /mandaye/static |
13 |
templates_directories: |
|
13 | 14 |
|
14 | 15 |
[debug] |
15 | 16 |
debug: false |
mandaye/template.py | ||
---|---|---|
4 | 4 |
|
5 | 5 |
from mandaye import config, global_config |
6 | 6 |
|
7 |
mylookup = TemplateLookup(directories=[config.template_directory, global_config.template_directory], |
|
7 |
templates_directories = config.templates_directories + [global_config.template_directory] |
|
8 |
mylookup = TemplateLookup(directories=templates_directories, |
|
8 | 9 |
input_encoding='utf-8') |
9 | 10 |
|
10 | 11 |
def serve_template(templatename, encoding='utf-8', **kwargs): |
Formats disponibles : Unified diff
templates: manage multi templates directories in the configuration