[PATCH 01 of 11] hgweb: use registrar to declare "websub" template filter

Yuya Nishihara yuya at tcha.org
Sat Mar 31 01:49:29 UTC 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1521459546 -32400
#      Mon Mar 19 20:39:06 2018 +0900
# Node ID eb32cf0cbbf309242f75d5b94f27744b1a1abd5d
# Parent  81951fe000108850cd19f4f1185f803e20778d1b
hgweb: use registrar to declare "websub" template filter

Prepares for adding 'intype' attribute.

diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -27,6 +27,7 @@ from .. import (
     hook,
     profiling,
     pycompat,
+    registrar,
     repoview,
     templatefilters,
     templater,
@@ -170,6 +171,9 @@ class requestcontext(object):
                              or req.apppath
                              or self.repo.root)
 
+        filters = {}
+        templatefilter = registrar.templatefilter(filters)
+        @templatefilter('websub')
         def websubfilter(text):
             return templatefilters.websub(text, self.websubtable)
 
@@ -191,7 +195,7 @@ class requestcontext(object):
         }
         tres = formatter.templateresources(self.repo.ui, self.repo)
         tmpl = templater.templater.frommapfile(mapfile,
-                                               filters={'websub': websubfilter},
+                                               filters=filters,
                                                defaults=defaults,
                                                resources=tres)
         return tmpl


More information about the Mercurial-devel mailing list