2012-09-13 15:27:34 +00:00
|
|
|
# ext/preprocessors.py
|
2016-12-16 11:59:19 +00:00
|
|
|
# Copyright (C) 2006-2016 the Mako authors and contributors <see AUTHORS file>
|
2012-09-13 15:27:34 +00:00
|
|
|
#
|
|
|
|
# This module is part of Mako and is released under
|
|
|
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
|
|
|
|
2016-12-16 11:59:19 +00:00
|
|
|
"""preprocessing functions, used with the 'preprocessor'
|
2012-09-13 15:27:34 +00:00
|
|
|
argument on Template, TemplateLookup"""
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
2016-12-16 11:59:19 +00:00
|
|
|
|
2012-09-13 15:27:34 +00:00
|
|
|
def convert_comments(text):
|
|
|
|
"""preprocess old style comments.
|
2016-12-16 11:59:19 +00:00
|
|
|
|
2012-09-13 15:27:34 +00:00
|
|
|
example:
|
2016-12-16 11:59:19 +00:00
|
|
|
|
2012-09-13 15:27:34 +00:00
|
|
|
from mako.ext.preprocessors import convert_comments
|
2016-12-16 11:59:19 +00:00
|
|
|
t = Template(..., preprocessor=convert_comments)"""
|
2012-09-13 15:27:34 +00:00
|
|
|
return re.sub(r'(?<=\n)\s*#[^#]', "##", text)
|