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

Nunjucks / Jinja / Django {% templates %} correct support? #1110

Closed
softshape opened this issue Jan 13, 2017 · 14 comments
Closed

Nunjucks / Jinja / Django {% templates %} correct support? #1110

softshape opened this issue Jan 13, 2017 · 14 comments

Comments

@softshape
Copy link

Right now the code like:

      </div>
      {% endfor %}
      {% if json.length == 5 %}
      <div class="col steps">&nbsp;</div>
      {% endif %}
    </div>

losts its linebreaks between template tags after formatting:

      </div>
      {% endfor %} {% if json.length == 5 %}
      <div class="col steps">&nbsp;</div>
      {% endif %}
    </div>

Any way to avoid that? This affects all {% %}, {# #}, and {{ }} tags.

@bitwiseman
Copy link
Member

#1104 might address your issue. Try it locally.

@softshape
Copy link
Author

I'm using js-beautify via Visual Studio Code extension https://github.com/lonefy/vscode-js-css-html-formatter. So I've updated the source in C:\Users\username.vscode\extensions\lonefy.vscode-JS-CSS-HTML-formatter-0.2.2\node_modules\js-beautify\ to the one downloaded from GitHub.

No any changes, it still removes linebreak between two template tags.

@rtpm
Copy link

rtpm commented Jun 26, 2017

Any progress on this?

Tried with vscode as of today (26.09.2017) and the problem still exists

If you need more info/debug let me know.

@bitwiseman
Copy link
Member

No progress. This needs someone to implement it.

@eromoe
Copy link

eromoe commented Jun 28, 2017

I have same problem
victorporof/Sublime-HTMLPrettify#360 (comment)

@york-xtrem
Copy link

I'm desperate! I've tried everything, I've tried things for Jinja2 and Twig but nothing. I don't know what to do...

@zellwk
Copy link

zellwk commented Dec 21, 2017

@bitwiseman any hints on how to implement something like this?

@bitwiseman
Copy link
Member

@koshkin-kna - no, sorry. The project your referred to is 4 years out of date from the current version of beautifier.

@beautifier beautifier deleted a comment from koshkin-kna Mar 3, 2018
@Viscmad
Copy link

Viscmad commented May 8, 2018

I am having this issue as well... :(

@MacKLess
Copy link
Collaborator

I just tried this code in v1.8.6 and it appears to no longer be an issue. @softshape do you want to double-check and let me know what you find? It does remove the indentation, but as that was not the issue with the original filed bug, I think it might be resolved.

@dancaron
Copy link

I am getting a linebreak after a {% in my django templates.

@bitwiseman
Copy link
Member

@dancaron What input are you providing? What version are you using?

@dancaron
Copy link

Input:

<div class="form-check form-check">
   <label class="form-check-label">
     <input class="radio" type="radio" v-model="jobPosition" value="1" {% if job.position.id == 1 %}checked{% endif %}>Full-Time
  </label>
</div>

Output:

<div class="form-check form-check">
    <label class="form-check-label">
        <input class="radio" type="radio" v-model="jobPosition" value="1" {% if
            job.position.id==1 %}checked{% endif %}>Full-Time
    </label>
</div>

Version: js-beautify 1.8.8 (vscode)

However: I noticed that if I use "format selection" the output does not include a line-break, and works as expected. If I use "format document" you will see the output as above.

@bitwiseman
Copy link
Member

@dancaron Try this on https://beautifier.io (v1.9.0-beta 3). It should be fixed now.

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

9 participants