support heritage
This commit is contained in:
parent
651d89dd04
commit
af8f0bfc9a
|
@ -34,16 +34,25 @@ from ...utils import normalize_family
|
|||
from ...error import TemplateError
|
||||
|
||||
|
||||
class CheetahTemplate(Template): # pylint: disable=W0223
|
||||
"""Construct a cheetah templating object
|
||||
@classmethod
|
||||
def cl_compile(kls, *args, **kwargs):
|
||||
"""Rewrite compile methode to force some settings
|
||||
"""
|
||||
compilerSettings = {'directiveStartToken' : '%',
|
||||
kwargs['compilerSettings'] = {'directiveStartToken' : '%',
|
||||
'cheetahVarStartToken' : '%%',
|
||||
'EOLSlurpToken' : '%',
|
||||
'commentStartToken' : '#',
|
||||
'multiLineCommentStartToken' : '#*',
|
||||
'multiLineCommentEndToken' : '*#',
|
||||
}
|
||||
return kls.old_compile(*args, **kwargs) # pylint: disable=E1101
|
||||
Template.old_compile = Template.compile
|
||||
Template.compile = cl_compile
|
||||
|
||||
|
||||
class CheetahTemplate(Template): # pylint: disable=W0223
|
||||
"""Construct a cheetah templating object
|
||||
"""
|
||||
def __init__(self,
|
||||
filename: str,
|
||||
source: str,
|
||||
|
@ -54,16 +63,12 @@ class CheetahTemplate(Template): # pylint: disable=W0223
|
|||
"""Initialize Creole CheetahTemplate
|
||||
"""
|
||||
if filename is not None:
|
||||
Template.__init__(self,
|
||||
file=filename,
|
||||
super().__init__(file=filename,
|
||||
searchList=[context, eosfunc, extra_context],
|
||||
compilerSettings=self.compilerSettings,
|
||||
)
|
||||
else:
|
||||
Template.__init__(self,
|
||||
source=source,
|
||||
super().__init__(source=source,
|
||||
searchList=[context, eosfunc, extra_context],
|
||||
compilerSettings=self.compilerSettings,
|
||||
)
|
||||
|
||||
# FORK of Cheetah function, do not replace '\\' by '/'
|
||||
|
|
|
@ -35,6 +35,23 @@ from ...utils import normalize_family
|
|||
from ...error import TemplateError
|
||||
|
||||
|
||||
@classmethod
|
||||
def cl_compile(kls, *args, **kwargs):
|
||||
"""Rewrite compile methode to force some settings
|
||||
"""
|
||||
kwargs['compilerSettings'] = {'directiveStartToken' : u'%',
|
||||
'cheetahVarStartToken' : u'%%',
|
||||
'EOLSlurpToken' : u'%',
|
||||
'PSPStartToken' : u'µ' * 10,
|
||||
'PSPEndToken' : u'µ' * 10,
|
||||
'commentStartToken' : u'µ' * 10,
|
||||
'commentEndToken' : u'µ' * 10,
|
||||
'multiLineCommentStartToken' : u'µ' * 10,
|
||||
'multiLineCommentEndToken' : u'µ' * 10}
|
||||
return kls.old_compile(*args, **kwargs) # pylint: disable=E1101
|
||||
oriCheetahTemplate.compile = cl_compile
|
||||
|
||||
|
||||
class IsDefined:
|
||||
"""
|
||||
filtre permettant de ne pas lever d'exception au cas où
|
||||
|
@ -58,15 +75,6 @@ class IsDefined:
|
|||
|
||||
|
||||
class CheetahTemplate(oriCheetahTemplate):
|
||||
compilerSettings = {'directiveStartToken' : '%',
|
||||
'cheetahVarStartToken' : '%%',
|
||||
'EOLSlurpToken' : '%',
|
||||
'PSPStartToken' : 'µ' * 10,
|
||||
'PSPEndToken' : 'µ' * 10,
|
||||
'commentStartToken' : 'µ' * 10,
|
||||
'commentEndToken' : 'µ' * 10,
|
||||
'multiLineCommentStartToken' : 'µ' * 10,
|
||||
'multiLineCommentEndToken' : 'µ' * 10}
|
||||
def __init__(self,
|
||||
filename: str,
|
||||
source: str,
|
||||
|
|
Loading…
Reference in New Issue