allow to use multiple directories in html and txt templates

remove from the config:
templates_dir, templates_dir_default, txt_templates_dir, txt_templates_dir_default

add to the config:
html_templates_dirs - a list of directories with html templates
txt_templates_dirs - a list of directories with txt templates

We search from the last directory to the first one.
This commit is contained in:
2026-06-21 01:59:32 +02:00
parent 9e1a3e336b
commit d35854691c
6 changed files with 33 additions and 26 deletions
+9 -6
View File
@@ -4,8 +4,8 @@
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2011-2015, Tomasz Sowa
/*
* Copyright (c) 2011-2026, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -59,13 +59,16 @@ void Patterns::SetDeleteWhiteItems(bool del_white)
}
void Patterns::SetDirectories(const std::wstring & tmpl_dir, const std::wstring & tmpl_dir_def)
void Patterns::SetDirectories(const std::vector<std::wstring> & tmpl_dirs)
{
templates_dir = tmpl_dir;
templates_dir_def = tmpl_dir_def;
templates_dirs = tmpl_dirs;
}
void Patterns::ClearDirectories()
{
templates_dirs.clear();
}
void Patterns::SetLocale(Locale * plocale)
@@ -138,7 +141,7 @@ void Patterns::ReadPatterns(Template & templ)
* pattern_parser.SetCommentary() is set beforehand
*/
pattern_parser.DeleteWhiteTextItems(del_white_items);
pattern_parser.Directory(templates_dir, templates_dir_def);
pattern_parser.SetDirectories(templates_dirs);
pattern_parser.SetLogger(&log);
if( ezc_blocks )
+5 -4
View File
@@ -4,8 +4,8 @@
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2011-2018, Tomasz Sowa
/*
* Copyright (c) 2011-2026, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -53,7 +53,8 @@ public:
Patterns();
void SetDeleteWhiteItems(bool del_white);
void SetDirectories(const std::wstring & tmpl_dir, const std::wstring & tmpl_dir_def);
void SetDirectories(const std::vector<std::wstring> & tmpl_dirs);
void ClearDirectories();
/*
setting locale and locale_filter
@@ -151,7 +152,7 @@ public:
private:
bool del_white_items;
std::wstring templates_dir, templates_dir_def;
std::vector<std::wstring> templates_dirs;
Locale * locale;
LocaleFilter * locale_filter;
+1 -1
View File
@@ -868,7 +868,7 @@ void Templates::Init()
{
using namespace TemplatesFunctions;
patterns.SetDirectories(config->templates_dir, config->templates_dir_default);
patterns.SetDirectories(config->html_templates_dirs);
pattern_cacher.SetWhenDelete(config->pattern_cacher_when_delete, config->pattern_cacher_how_many_delete);
CreateFunctions(); // create functions first (functions will be cached by patterns)
ReadTemplates();