Skip to content

Highlighting of inline Jinja2 templates #23

Closed

Description

@tfeldmann

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

Activity

  1. 1st1 commented on Nov 6, 2015

    @1st1
    Member

    % 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?

  2. vpetrovykh commented on Nov 6, 2015

    @vpetrovykh
    Contributor

    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.

  3. vpetrovykh commented on Nov 6, 2015

    @vpetrovykh
    Contributor

    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.

  4. 1st1 commented on Nov 6, 2015

    @1st1
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions