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

login
register
mail settings
Submitter Yuya Nishihara
Date March 31, 2018, 1:49 a.m.
Message ID <eb32cf0cbbf309242f75.1522460969@mimosa>
Download mbox | patch
Permalink /patch/30039/
State Accepted
Headers show

Comments

Yuya Nishihara - March 31, 2018, 1:49 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.

Patch

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