comparison mercurial/hgweb/hgweb_mod.py @ 28954:f97a0bcfd7a1

templater: separate function to create templater from map file (API) New frommapfile() function will make it clear when template aliases will be loaded. They should be applied to command arguments and templates in hgrc, but not to map files. Otherwise, our stock styles and web templates (i.e map-file templates) could be modified unintentionally. Future patches will add "aliases" argument to __init__(), but not to frommapfile().
author Yuya Nishihara <yuya@tcha.org>
date Sun, 03 Apr 2016 23:26:48 +0900
parents 37fcfe52c68c
children 80df04266a16
comparison
equal deleted inserted replaced
28953:7f6b8ec691e3 28954:f97a0bcfd7a1
186 def websubfilter(text): 186 def websubfilter(text):
187 return templatefilters.websub(text, self.websubtable) 187 return templatefilters.websub(text, self.websubtable)
188 188
189 # create the templater 189 # create the templater
190 190
191 tmpl = templater.templater(mapfile, 191 defaults = {
192 filters={'websub': websubfilter}, 192 'url': req.url,
193 defaults={'url': req.url, 193 'logourl': logourl,
194 'logourl': logourl, 194 'logoimg': logoimg,
195 'logoimg': logoimg, 195 'staticurl': staticurl,
196 'staticurl': staticurl, 196 'urlbase': urlbase,
197 'urlbase': urlbase, 197 'repo': self.reponame,
198 'repo': self.reponame, 198 'encoding': encoding.encoding,
199 'encoding': encoding.encoding, 199 'motd': motd,
200 'motd': motd, 200 'sessionvars': sessionvars,
201 'sessionvars': sessionvars, 201 'pathdef': makebreadcrumb(req.url),
202 'pathdef': makebreadcrumb(req.url), 202 'style': style,
203 'style': style, 203 }
204 }) 204 tmpl = templater.templater.frommapfile(mapfile,
205 filters={'websub': websubfilter},
206 defaults=defaults)
205 return tmpl 207 return tmpl
206 208
207 209
208 class hgweb(object): 210 class hgweb(object):
209 """HTTP server for individual repositories. 211 """HTTP server for individual repositories.