Signed-off-by: Jean Privat <jean@pryen.org>
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 = dhref.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)
+ tpl.replace("ROOT_URL", root_href)
end
return tpl
end
# Relative path to the directory `self` from the target root_url
fun dir_href: String do return href.dirname
+ # Relative path to the root url from `self`
+ fun root_href: String do
+ var root_dir = dir_href.relpath("")
+ # Avoid issues if used as a macro just followed by a `/` (as with url prefix)
+ if root_dir == "" then root_dir = "."
+ return root_dir
+ end
+
# A relative `href` to `self` from the page `context`.
#
# Should be used to navigate between documents.