Mako Templates: Mapping between line numbers before rendering and after
rendering
In our project we are using Mako Templates with tool version 0.4.0 . We
have created some base template files for a Python based Domain Specific
Language(DSL). In addition to these templates, some configurations in the
form of a dictionary are passed to MakoTemplate.render method to generate
the final internal DSL format file for further processing.
The template files include :
1. <% ... %> sections
2. %if ... %endif sections
3. %for ... %endfor sections.
For our project Mako is working great and generating the DSL files in
perfect formats as per our expectations.
The actual problem started when recently I initiated writing our DSL
specific editor which is capable of detecting some domain related errors
in the internally generated files (Mako output).
Now with some algorithm, I am able to detect the erroneous lines in these
generated file. But I need to mark these erroneous lines on the original
template file and to accomplish this I need a mapping between the line
numbers of the output generated file(internal) and the line numbers in
base template file which include Mako statements (listed above).
Is there a way which during rendering, can give me such a mapping ?
Please help.
thanks and regards, farhat
No comments:
Post a Comment