# HG changeset patch # User Vadim Gelfer # Date 2006-03-15 19:28:00 # Node ID 778281d46bb27c795934a268b79486e0f6b93052 # Parent 39eb64b23cb5c1b43ecf6cf43080fa648e00c665 fix template bug that made hgweb break. problem found by Shun-ichi Goto . this fix tested with command template and hgweb templates. diff --git a/mercurial/hgweb.py b/mercurial/hgweb.py --- a/mercurial/hgweb.py +++ b/mercurial/hgweb.py @@ -797,11 +797,11 @@ class hgweb(object): or uri.strip('/') or self.repo.root) self.t = templater.templater(m, templater.common_filters, - {"url": url, - "repo": self.reponame, - "header": header, - "footer": footer, - }) + defaults={"url": url, + "repo": self.reponame, + "header": header, + "footer": footer, + }) if not req.form.has_key('cmd'): req.form['cmd'] = [self.t.cache['default'],] @@ -1030,7 +1030,8 @@ class hgwebdir(object): m = os.path.join(templater.templatepath(), "map") tmpl = templater.templater(m, templater.common_filters, - {"header": header, "footer": footer}) + defaults={"header": header, + "footer": footer}) def entries(**map): parity = 0 diff --git a/mercurial/templater.py b/mercurial/templater.py --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -59,18 +59,17 @@ class templater(object): filter uses function to transform value. syntax is {key|filter1|filter2|...}.''' - def __init__(self, mapfile, filters={}, cache={}): + def __init__(self, mapfile, filters={}, defaults={}, cache={}): '''set up template engine. mapfile is name of file to read map definitions from. filters is dict of functions. each transforms a value into another. defaults is dict of default map definitions.''' self.mapfile = mapfile or 'template' - self.cache = {} + self.cache = cache self.map = {} self.base = (mapfile and os.path.dirname(mapfile)) or '' self.filters = filters - self.defaults = {} - self.cache = cache + self.defaults = defaults if not mapfile: return