Atom-beautify: issues in Django Templates

Created on 9 Aug 2016  路  11Comments  路  Source: Glavin001/atom-beautify

Description

when i use atom-beautify for Django Templates code

    <link rel="stylesheet" href="{% static "css/lightbox.css" %}">

add space between static ""

    <link rel="stylesheet" href="{% static " css/lightbox.css " %}">

Expected Results

The beautified code should have looked like:

    <link rel="stylesheet" href="{% static "css/lightbox.css" %}">

Steps to Reproduce

  1. Add code to Atom editor
  2. Run command Atom Beautify: Beautify Editor
  3. This beautified code does not look right!

    Debug

Here is a link to the debug.md Gist:

Checklist

  • [Y] I have tried uninstalling and reinstalling Atom Beautify to ensure it installed properly
  • [Y] I have reloaded (or restarted) Atom to ensure it is not a caching issue
  • [ ] Searched for existing Atom Beautify Issues at https://github.com/Glavin001/atom-beautify/issues
    so I know this is not a duplicate issue
  • [ ] Generated debugging information and added link for debug.md Gist to this issue
third-party-bug

Most helpful comment

In the mean time you can immediately solve this problem by converting those two middle double quotes to single quotes.

All 11 comments

I need you to generate Atom Beautify's debug.md file and paste it to a gist. The defect is most likely in Pretty Diff and most likely related to the nested quotes... but I want to be certain.

In the mean time you can immediately solve this problem by converting those two middle double quotes to single quotes.

I just enhanced Pretty Diff's markup parser to support this on its branch 2.1.3. I would still like the debug.md file in case you are not using Pretty Diff as your beautifier.

Awesome. Opening an issue with JSBeautify.

Closing this as a third-party bug.

Updated today and still seeing this issue. Using better syntax fixed the parsing issue as recommended above.

@spaceneenja which grammars worked and which did not work for you? We could change Atom-Beautify's default beautifiers for Django.

Sure, I changed:

<a href="{% url "order" %}">
<link type='text/less' rel="stylesheet" href="{% static "less/header.less" %}">

To:

<a href="{% url 'order' %}">
<link type='text/less' rel="stylesheet" href="{% static 'less/header.less' %}">

Now it works just fine!

Oh, so this isn't a bug? Just need to not use double-quotes (e.g. ") within double-quotes? Awesome! 馃憤

Exactly. It is valid Django syntax however, so I suppose beautify shouldn't mess with it.

Beautify adds a space before and after each item in the second quotes.
<a href="{% url " order " %}">

Updating someone's dirty old code however was a quick and easy fix and seems so obvious now.

Awesome package btw!

Was this page helpful?
0 / 5 - 0 ratings