Interaction with outer language for template language

I'm developing a template language called Pyxl that is used to embed html inside of Python files. The html expressions themselves are representing objects, which are assignable to Python names.

For example:

header = <header><h1>Welcome</h1></header>


would be resolved to something along the lines of:

header = x_header().append(x_h1().append(text('Welcome'));



Right now I have implemented the templating language so that it correct embeds the Pyxl language inside of Python, but I run into problems where the assigment above occurs, since the Pyxl content is taken out of the Python environment.

The Pyxl context see:

header = <header><h1>Welcome</h1></header>


which is fine, but in turn the Python context see:

header = <header><h1>Welcome</h1></header>


which is an invalid statement causeing a red error mark.

Does anyone have any idea on how I can solve this?

A screenshot to better illustrate the problem:

Screenshot 2014-05-28 00.06.23.png
1 comment

If you just don't want to see the red warning, you can suppress it with HighlightErrorFilter/HighlightInfoFilter extensions.

If you don't want Python highlighter to issue those warnings, then it should be prepared to OuterLanguageElements everywhere, and the highlighting code should be changed accordingly. You can create pull requests for that, but that's a lot of work. So I'd go with the first variant.

0

Please sign in to leave a comment.