comparison mercurial/hgweb/hgwebdir_mod.py @ 36989:de117f579431

templater: factor out helper that renders named template as string This is quite common in non-web templating, and **kwargs expansion is annoying because of the unicode-ness of Python3.
author Yuya Nishihara <yuya@tcha.org>
date Fri, 16 Mar 2018 21:24:12 +0900
parents c479692690ef
children c97b936d8bb5
comparison
equal deleted inserted replaced
36988:317382151ac3 36989:de117f579431
33 hg, 33 hg,
34 profiling, 34 profiling,
35 pycompat, 35 pycompat,
36 scmutil, 36 scmutil,
37 templater, 37 templater,
38 templateutil,
39 ui as uimod, 38 ui as uimod,
40 util, 39 util,
41 ) 40 )
42 41
43 from . import ( 42 from . import (
379 if csp: 378 if csp:
380 res.headers['Content-Security-Policy'] = csp 379 res.headers['Content-Security-Policy'] = csp
381 380
382 virtual = req.dispatchpath.strip('/') 381 virtual = req.dispatchpath.strip('/')
383 tmpl = self.templater(req, nonce) 382 tmpl = self.templater(req, nonce)
384 ctype = tmpl('mimetype', encoding=encoding.encoding) 383 ctype = tmpl.render('mimetype', {'encoding': encoding.encoding})
385 ctype = templateutil.stringify(ctype)
386 384
387 # Global defaults. These can be overridden by any handler. 385 # Global defaults. These can be overridden by any handler.
388 res.status = '200 Script output follows' 386 res.status = '200 Script output follows'
389 res.headers['Content-Type'] = ctype 387 res.headers['Content-Type'] = ctype
390 388