Link to syntax: http://jinja.pocoo.org/docs/dev/
Example:
<title>{% block title %}{% endblock %}</title>
<ul>
{% for user in users %}
<li><a href="{{ user.url }}">{{ user.username }}</a></li>
{% endfor %}
</ul>
This should also add support for Nunjucks as well!
Would LOVE to see Jinja2 support as well!
:+1:
I would love this feature as well...
:+1:
+1
I am already supporting the syntax as you can test at http://prettydiff.com/?m=beautify but to creep closer towards perfection I need help determine which template tag names should cause additional indentation. For example in the sample at the top of this thread there is <% for ... %> that increases indentation and <% endfor %> that decreases indentation.
Once I can account for the vocabulary that interferes with indentation we will be solid. In the meantime you can beautify away without the extra indentation if you change your HTML beautifier to Pretty Diff in the Atom Beautify settings or beautify as XML.
What about "style": "noindent" so that <style> tags don't become 1 line.
Style tags shouldn't become one line and if they do please provide me a code sample in case you have found a defect.
Found that removing media="screen" from the <style> tag fixes this.
<style type="text/css" media="screen">
body {
margin-top: 0 !important;
margin-bottom: 0 !important;
padding-top: 0 !important;
padding-bottom: 0 !important;
width: 100% !important;
-webkit-text-size-adjust: 100% !important;
-ms-text-size-adjust: 100% !important;
-webkit-font-smoothing: antialiased !important;
}
</style>
I still think that is a defect. Attributes on the style tag should have no bearing on how the CSS code is beautified.
@prettydiff You're right. I'll start a new issue.
I can confirm the defect on Pretty Diff and not on JS Beautify. I am working this now.
In Nunjucks elseif is actually elif. I have no idea why they went with that convention. It would be nice to have support for this.
@rickysullivan Thanks, I will work that in let you know when the update is published.
@rickysullivan I published this change in v1.16.34.
:+1:
+1
This should already be resolved. If there are remaining problems please reopen this issue.
Do I understand this right, that jinja2 support has been implemented for prettydiff.com, but not for atom-beautify? I am still having issues with the atom package, for example, it gives me
{% endif %} {% if DISQUS_SITENAME %} {% include "disqus.html" %} {% endif %}
Sorry in advance for all the at's.
@prettydiff like @art1fa asked, it appears this was applied to prettydiff.com but not atom-beautify. I see @Glavin001 was assigned this one, but since it was closed I'm not sure he saw it. Could we get it re-opened?
Thanks guys!
@art1fa and @mkell43 : Please create a Gist with the results from running Atom Beautify: Help Debug Editor command: https://github.com/Glavin001/atom-beautify/blob/master/CONTRIBUTING.md#new-issues-bugs-questions-etc
This will help us see the input, output, and options used in the beautifier. Also @prettydiff could you confirm the fix was published to npm registry? Otherwise users will need to wait on the latest Pretty Diff being published.
I am looking back at the comment history to determine the status of things. It looks like the last reported defect or missing feature was reported and fixed in 11 March 2016 with version 1.16.34. I am testing all concerned code samples in version 1.16.37 (the version in Atom Beautify) and everything seems correct. I have also passed the code samples through the latest version of Pretty Diff and there does not appear to be any regression.
The only things I can determine from the code sample provided by @art1fa is that Pretty Diff is behaving in the same way with versions 2.1.17 (current development, not published) and 1.16.37. This code is very brief and appears to be operating correctly except that it starts with {% endif %}, which is an end tag. At the very least the code displays on 4 lines, and is indented properly once I removed the end tag at the beginning. I cannot get the code to display on a single line. I will need a larger code sample to debug further but debug.md file would be better. @mkell43 if you are able to reproduce the defect and then please create a debug.md of your own.
@Glavin001 and @prettydiff Sorry for my delay in getting back to you guys. Thanks for responding. The gist is in the link below.
https://gist.github.com/mkell43/14e558d9af83e6b9576331bdde35e41a
However, I'm not entirely sure it's what you were expecting. When I go to start the debug editor that just pops up straight away.
As for what specifically I'm seeing, when doing alt+ctrl+b or running through the command palette is the following message.
Atom Beautify could not determine a supported beautifier to handle this file with grammar "Generic Config (Jinja Templates)" and extension "j2". If you would like to request support for this file and its language, please create an issue for Atom Beautify at https://github.com/Glavin001/atom-beautify/issues
And when I tell atom it's an HTML Jinja Template.
Atom Beautify could not determine a supported beautifier to handle this file with grammar "HTML (Jinja Templates)" and extension "j2". If you would like to request support for this file and its language, please create an issue for Atom Beautify at https://github.com/Glavin001/atom-beautify/issues
@mkell43 Ahhh, that just means Atom Beautify is not configured to support that specific grammar name and file extension. You can fix this with a pull request by extending one of the existing language files: https://github.com/Glavin001/atom-beautify/tree/master/src/languages
in 9 months we didn't find someone who's willing to make a coffe (file) for the community :-1:
I don't really know the syntax of those files, and I should go through the options.... is someone knowledgable with coffe willing to fix this? The extension is j2
Most helpful comment
@rickysullivan I published this change in v1.16.34.