diff mercurial/hgweb/hgweb_mod.py @ 28954:f97a0bcfd7a1

templater: separate function to create templater from map file (API) New frommapfile() function will make it clear when template aliases will be loaded. They should be applied to command arguments and templates in hgrc, but not to map files. Otherwise, our stock styles and web templates (i.e map-file templates) could be modified unintentionally. Future patches will add "aliases" argument to __init__(), but not to frommapfile().
author Yuya Nishihara <yuya@tcha.org>
date Sun, 03 Apr 2016 23:26:48 +0900
parents 37fcfe52c68c
children 80df04266a16
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py	Sun Apr 03 23:18:30 2016 +0900
+++ b/mercurial/hgweb/hgweb_mod.py	Sun Apr 03 23:26:48 2016 +0900
@@ -188,20 +188,22 @@
 
         # create the templater
 
-        tmpl = templater.templater(mapfile,
-                                   filters={'websub': websubfilter},
-                                   defaults={'url': req.url,
-                                             'logourl': logourl,
-                                             'logoimg': logoimg,
-                                             'staticurl': staticurl,
-                                             'urlbase': urlbase,
-                                             'repo': self.reponame,
-                                             'encoding': encoding.encoding,
-                                             'motd': motd,
-                                             'sessionvars': sessionvars,
-                                             'pathdef': makebreadcrumb(req.url),
-                                             'style': style,
-                                            })
+        defaults = {
+            'url': req.url,
+            'logourl': logourl,
+            'logoimg': logoimg,
+            'staticurl': staticurl,
+            'urlbase': urlbase,
+            'repo': self.reponame,
+            'encoding': encoding.encoding,
+            'motd': motd,
+            'sessionvars': sessionvars,
+            'pathdef': makebreadcrumb(req.url),
+            'style': style,
+        }
+        tmpl = templater.templater.frommapfile(mapfile,
+                                               filters={'websub': websubfilter},
+                                               defaults=defaults)
         return tmpl