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 @@ -140,11 +140,6 @@ class requestcontext(object): if not staticurl.endswith('/'): staticurl += '/' - # some functions for the templater - - def motd(**map): - yield self.config('web', 'motd') - # figure out which style to use vars = {} @@ -177,12 +172,16 @@ class requestcontext(object): 'urlbase': req.advertisedbaseurl, 'repo': self.reponame, 'encoding': encoding.encoding, - 'motd': motd, 'sessionvars': sessionvars, 'pathdef': makebreadcrumb(req.apppath), 'style': style, 'nonce': self.nonce, } + templatekeyword = registrar.templatekeyword(defaults) + @templatekeyword('motd', requires=()) + def motd(context, mapping): + yield self.config('web', 'motd') + tres = formatter.templateresources(self.repo.ui, self.repo) tmpl = templater.templater.frommapfile(mapfile, filters=filters, diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -33,6 +33,7 @@ from .. import ( hg, profiling, pycompat, + registrar, scmutil, templater, templateutil, @@ -495,12 +496,6 @@ class hgwebdir(object): def templater(self, req, nonce): - def motd(**map): - if self.motd is not None: - yield self.motd - else: - yield config('web', 'motd') - def config(section, name, default=uimod._unset, untrusted=True): return self.ui.config(section, name, default, untrusted) @@ -520,7 +515,6 @@ class hgwebdir(object): defaults = { "encoding": encoding.encoding, - "motd": motd, "url": req.apppath + '/', "logourl": logourl, "logoimg": logoimg, @@ -529,5 +523,13 @@ class hgwebdir(object): "style": style, "nonce": nonce, } + templatekeyword = registrar.templatekeyword(defaults) + @templatekeyword('motd', requires=()) + def motd(context, mapping): + if self.motd is not None: + yield self.motd + else: + yield config('web', 'motd') + tmpl = templater.templater.frommapfile(mapfile, defaults=defaults) return tmpl