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

can't work in vscode(1.16.1) #19

Open
ywyt738 opened this issue Sep 19, 2017 · 6 comments
Open

can't work in vscode(1.16.1) #19

ywyt738 opened this issue Sep 19, 2017 · 6 comments
Assignees
Milestone

Comments

@ywyt738
Copy link

ywyt738 commented Sep 19, 2017

it only syntax highlighting for jinja not for html.

_20170919230236

but another plugin Django Template is ok.

2

@mhubig
Copy link

mhubig commented Sep 20, 2017

Same problem here ...

@alochym01
Copy link

same here
it auto convert look like this:
`{% extends "base.html" %} {% block content_title %}Welcome to my blog{% endblock %} {% block content %}

Welcome to my blog {{ name }}

{% endblock %}`

@wholroyd
Copy link
Owner

wholroyd commented Oct 2, 2017

When the extension originally shipped, it could handle mixed languages with problem. Along the way, somewhere around version 1.4, they changed how languages where loaded/used in the editor and broke existing installs of this extension. The change made it easier to introduce mixed languages, but only if your language within a closure of the parent language in the page - like CSS or JS within an HTML page. The page will always start with HTML elements, but the same is not true for Jinja, where it could be the root/parent language or a child language.

There is a very costly way of getting around this by rewriting the extension and creating custom language files for each language that could be used with Jinja, or even writing a language service for Jinja that somehow hands off to other language services for things that aren't part of Jinja (assuming there even is a language service for the other language). Or just wait for the Visual Studio Code team to change/fix the mixed language logic.

I'm not the only one with this issue, there are other template-type languages that need the same components I do, but until Code moves away from strictly using the Textmate logic, I'm not going to be able to fix the extension to be the way it should be. I just don't have the time for it.

See microsoft/vscode#670 about just mixing PHP and HTML, which is a far more popular language mix than Jinja + anything has been around since 2015.

I use Jinja almost everyday with Ansible templates, so I'm personally impacted by this issue myself, so I'm in the same boat as all of you. For the time being, I've been using JetBrain's PyCharm, which has a free community edition that doesn't have this language mix issue.

If they fix the issue, I'll be all over it trying to get this extension to work again. Until then, this is a Jinja only plugin that is not guaranteed to work in any mixed language scenarios.

@varoot
Copy link

varoot commented Oct 8, 2017

I think it should be noted in the README that the base language (in this. case, HTML) should be selected and not Jinja. Then the problem is only when Jinja is used within HTML quotes (see the third line in the screenshot below). I think a lot of people will find this quite acceptable.

Screenshot

@danilaml
Copy link

I've found another plugin (Better Jinja) that doesn't have this issue - https://github.com/samuelcolvin/jinjahtml-vscode . It seems to be in a more active development as well.

@myrdd
Copy link

myrdd commented Oct 9, 2018

See also microsoft/vscode#40285

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

7 participants