##// END OF EJS Templates
core: use a custom filter for rendering all mako templates....
marcink -
r1949:8462771d default
parent child Browse files
Show More
@@ -273,6 +273,11 b' def includeme(config):'
273 273 if asbool(settings.get('appenlight', 'false')):
274 274 config.include('appenlight_client.ext.pyramid_tween')
275 275
276 if not 'mako.default_filters' in settings:
277 # set custom default filters if we don't have it defined
278 settings['mako.imports'] = 'from rhodecode.lib.base import h_filter'
279 settings['mako.default_filters'] = 'h_filter'
280
276 281 # Includes which are required. The application would fail without them.
277 282 config.include('pyramid_mako')
278 283 config.include('pyramid_beaker')
@@ -27,6 +27,7 b' controllers'
27 27 import logging
28 28 import socket
29 29
30 import markupsafe
30 31 import ipaddress
31 32 import pyramid.threadlocal
32 33
@@ -570,6 +571,17 b' class BaseController(WSGIController):'
570 571 return WSGIController.__call__(self, environ, start_response)
571 572
572 573
574 def h_filter(s):
575 """
576 Custom filter for Mako templates. Mako by standard uses `markupsafe.escape`
577 we wrap this with additional functionality that converts None to empty
578 strings
579 """
580 if s is None:
581 return markupsafe.Markup()
582 return markupsafe.escape(s)
583
584
573 585 class BaseRepoController(BaseController):
574 586 """
575 587 Base class for controllers responsible for loading all needed data for
General Comments 0
You need to be logged in to leave comments. Login now