Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlighting of inline Jinja2 templates #23

Closed
tfeldmann opened this issue Nov 6, 2015 · 4 comments
Closed

Highlighting of inline Jinja2 templates #23

tfeldmann opened this issue Nov 6, 2015 · 4 comments

Comments

@tfeldmann
Copy link

MagicPython seems to have problems highlighting Jinja2 templates (it shouldn't hightlight {% f and {% e, see screenshot)

bildschirmfoto 2015-11-06 um 12 15 47

@1st1
Copy link
Member

1st1 commented Nov 6, 2015

% f and % e are highlighted because it's a valid printf-style formatting syntax. I don't think we can do something about this. @vpetrovykh?

@vpetrovykh
Copy link
Member

The short answer is that we actually could fix this in a similar way as #12. Essentially this would extend the already existing fix.
The overall strategy would be to stop highlighting {}-formatting and %-formatting upon detection of a {%...%}. This would be in the spirit of not getting in the way, since in any string that happens to use {%...%}, chances are that neither {}-formatting nor %-formatting will be applied, so highlighting them is a visual distraction. Having said that, we will not actually try to treat {%...%} as anything special either since that involves assumptions about what kind of template we're, in fact, seeing.
We do have future plans for making it possible to configure what things will be highlighted in the strings, so I think that this is a good use-case for us to consider.

@vpetrovykh
Copy link
Member

Please note that any special escaped characters will still be highlighted (unless the string is raw, in the current implementation of the highlighter prefixed by R to tell apart form regexp prefixed r).
@1st1 please review my fix for this and make a release if it looks good.

@1st1
Copy link
Member

1st1 commented Nov 6, 2015

Should be fixed in v0.4.43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants