1 | """preprocessing functions, used with the 'preprocessor' argument on Template, TemplateLookup""" |
---|
2 | |
---|
3 | import re |
---|
4 | |
---|
5 | def convert_comments(text): |
---|
6 | """preprocess old style comments. |
---|
7 | |
---|
8 | example: |
---|
9 | |
---|
10 | from mako.ext.preprocessors import convert_comments |
---|
11 | t = Template(..., preprocessor=preprocess_comments)""" |
---|
12 | return re.sub(r'(?<=\n)\s*#[^#]', "##", text) |
---|
13 | |
---|
14 | # TODO |
---|
15 | def create_tag(callable): |
---|
16 | """given a callable, extract the *args and **kwargs, and produce a preprocessor |
---|
17 | that will parse for <%<funcname> <args>> and convert to an appropriate <%call> statement. |
---|
18 | |
---|
19 | this allows any custom tag to be created which looks like a pure Mako-style tag.""" |
---|
20 | raise NotImplementedError("Future functionality....") |
---|