Signed-off-by: Jean Privat <jean@pryen.org>
end
var file = expand_path(config.root_dir, config.templates_dir, name)
var tpl = new TemplateString.from_file(file)
- if tpl.has_macro("ROOT_URL") then
- tpl.replace("ROOT_URL", config.root_url)
- end
if tpl.has_macro("TITLE") then
tpl.replace("TITLE", config.wiki_name)
end
# Load a template and resolve page-related macros
fun load_template(template_file: String): TemplateString do
var tpl = wiki.load_template(template_file)
+ if tpl.has_macro("ROOT_URL") then
+ var root_dir = href.dirname.relpath("")
+ # Avoid issues if the macro is just followed by a `/` (as with url prefix)
+ if root_dir == "" then root_dir = "."
+ tpl.replace("ROOT_URL", root_dir)
+ end
return tpl
end