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