diff mercurial/templatefilters.py @ 28692:6b3b958daf03

registrar: add templatefilter to mark a function as template filter (API) This patch also adds loadfilter() to templatefilters, because this combination helps to figure out how they cooperate with each other. Listing up loadfilter() in dispatch.extraloaders causes implicit loading template filter functions at loading (3rd party) extension. This change requires that "templatefilter" attribute of (3rd party) extension is registrar.templatefilter or so.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Wed, 30 Mar 2016 02:10:44 +0900
parents 93b5c540db69
children 11f623b5668f
line wrap: on
line diff
--- a/mercurial/templatefilters.py	Sun Feb 14 20:43:30 2016 +0900
+++ b/mercurial/templatefilters.py	Wed Mar 30 02:10:44 2016 +0900
@@ -415,5 +415,11 @@
             text = regexp.sub(format, text)
     return text
 
+def loadfilter(ui, extname, registrarobj):
+    """Load template filter from specified registrarobj
+    """
+    for name, func in registrarobj._table.iteritems():
+        filters[name] = func
+
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = filters.values()