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

Commenting on Django Templates incorrect #10

Open
willvanwazer opened this Issue Jan 18, 2012 · 27 comments

Comments

Projects
None yet
10 participants
@willvanwazer
Copy link

willvanwazer commented Jan 18, 2012

When the shortcut for commenting is pressed (Command - / ), comments are presented as standard HTML, rather than Django templates (as with the TextMate bundle).

@EyePulp

This comment has been minimized.

Copy link

EyePulp commented Jan 27, 2012

Agreed, this is pretty annoying. I'd also like to be able to do multiple line commenting ala textmate, rather than the {% comment %} block.

@squ1b3r

This comment has been minimized.

Copy link
Owner

squ1b3r commented Jan 27, 2012

What do you mean "rather than the {% comment %} block"? In Django {# this is line comment #} and {% comment %}this is block comment{% endcomment %}.

p.s. I'm working on it.

@EyePulp

This comment has been minimized.

Copy link

EyePulp commented Jan 27, 2012

Sorry for not being more clear. In the Javascript module under SublimeText2 (ST2), if you select multiple lines and hit cmd+/ each individual line gets a leading // instead of the "correct" multiline comment mechanism in JS, which is /* ... */

I like how that works in ST2, and it mirrors the behavior in TextMate (TM). My personal preference for HTML (Django) templates would be the same behavior. e.g a single or multi-line comment would always result in {# ... #} wrapping every individual line. That makes it very easy to "turn off" whole areas and then selectively turn bits back on, all with the same key combo - cmd+/

I went through the TM .tmPreferences to see if I could figure it out, but couldn't get it behaving quite right. I'm guessing it's possible, but I'm just too thick to see it. =)

@zene

This comment has been minimized.

Copy link

zene commented Sep 27, 2012

I'm having the same issue. It would be great if we could have block comments work on every line with {# ... #}

@squ1b3r

This comment has been minimized.

Copy link
Owner

squ1b3r commented Sep 27, 2012

Unfortunately ST2 cannot do different types of commenting even for built-in languages like javascript. So I still waiting when John get this thing done.

@zene

This comment has been minimized.

Copy link

zene commented Sep 27, 2012

I see, it looks like ST2 just doesn't recognize the TM_COMMENT_MODE, etc. No fault of yours. Hopefully this is added sometime in the near future for ST2!

@squ1b3r

This comment has been minimized.

Copy link
Owner

squ1b3r commented Sep 27, 2012

I really hope so

@natecox

This comment has been minimized.

Copy link
Contributor

natecox commented Sep 3, 2013

I'd really like it if I could get the package to use {% comment %} blocks instead of {# #}.

i.e., ctrl+shift+/ takes a selected section from

This is a test
With some more text.

to

{% comment %}
  This is a test
  With some more text
{% endcomment %}

I'm still pretty new to how snippets and so forth work, though. Could anyone give me some direction on how I'd get this functionality to work?

@squ1b3r

This comment has been minimized.

Copy link
Owner

squ1b3r commented Sep 4, 2013

I'm working on this one. Unfortunately ST2-3 doesn't have support for TM_COMMENT_MODE yet so I'm rewriting whole comment/uncomment thingy. I really hope I will have something working by the end of this week. Thanks.

@zene

This comment has been minimized.

Copy link

zene commented Sep 4, 2013

Hi tsuujin. Yes, it is possible to change the behavior (for now, until squ1b3r updates, which would be awesome) so that you get {% comment %} instead of {#.

To do this, follow the directions at http://www.sublimetext.com/docs/3/packages.html, the very bottom paragraph basically tells you what you need to do. I installed using package control, so these are the steps I performed to get it working.

  1. From Sublime Text click Sublime Text > Preferences > Browse Packages
  2. Click on the Installed Packages directory
  3. Copy Djaneiro.sublime-package
  4. Rename copy to Djaneiro.zip and then unzip
  5. Delete everything else out of the new Djaneiro directory except for the Syntax Preferences folder
  6. Edit the <executable_path>/Installed Packages/Djaneiro/Syntax Preferences/Comments.tmPreferences file
  7. Change {# to {% comment %} and #} to {% endcomment %} and save the file
  8. Close and reopen Sublime Text
@squ1b3r

This comment has been minimized.

Copy link
Owner

squ1b3r commented Sep 4, 2013

Or you can use comment snippet which works with selection.

@natecox

This comment has been minimized.

Copy link
Contributor

natecox commented Sep 5, 2013

@squ1b3r Sure, you can do that, but it's a heck of a lot more keystrokes than just using the shortcut.

My project requires that I use Django 1.4, and the {# #} format actually places those tags all over my final result for one reason or another (also I just don't like them).

@chris-erickson

This comment has been minimized.

Copy link

chris-erickson commented Mar 14, 2014

It took me a while to discover that this was a actually a problem (hopefully this helps others zero in on this). I would really like the block comment to add the full comment tag. The shortcut works, but as @natecox hits on, it's quite a pain for something that you may be toggling in quick succession.

Should I change the default comment style for now, or do you think an update to this might be available sometime soon?

@squ1b3r

This comment has been minimized.

Copy link
Owner

squ1b3r commented Mar 14, 2014

Your best bet is to change default comment style for now. Not really sure when next update will be to be honest.

@chris-erickson

This comment has been minimized.

Copy link

chris-erickson commented Apr 10, 2014

As an alternative, is it possible to assign bind a key to this snippet? I tried:

{ "keys": ["ctrl+/"], "command": "insert_snippet", "args": {"name": "Installed Packages/Djaneiro/comment.sublime-snippet"} }

but it didn't activate. Though I confess I couldn't find great info on exactly the right syntax.

@squ1b3r

This comment has been minimized.

Copy link
Owner

squ1b3r commented Apr 11, 2014

The path is a bit incorrect. The right way to do it would be something like this:

{ "keys": ["ctrl+/"], "command": "insert_snippet", "args": {"name": "Packages/Djaneiro/html/comment.sublime-snippet"} }
@chris-erickson

This comment has been minimized.

Copy link

chris-erickson commented Apr 17, 2014

Thanks, that did it for me!

@kaflesudip

This comment has been minimized.

Copy link

kaflesudip commented Oct 20, 2014

Any chance that the plugin will be updated to include {% comment %} instead of {#... #}?

@squ1b3r

This comment has been minimized.

Copy link
Owner

squ1b3r commented Oct 20, 2014

ST2 currently does not support block comments properly and there is no way to do that without hacking its comments system. So I guess using snippets for that would be your best bet right now.

@natecox

This comment has been minimized.

Copy link
Contributor

natecox commented Oct 20, 2014

Is there a particular reason you're supporting ST2 instead of ST3? Does ST3 do what you need it to do?

@squ1b3r

This comment has been minimized.

Copy link
Owner

squ1b3r commented Oct 21, 2014

There is no difference between ST2 and ST3 in this case. Comment system works exactly the same and Djaneiro works fine for both ST2 and ST3

@admed

This comment has been minimized.

Copy link

admed commented Nov 18, 2016

How is the progress on this issue?

@squ1b3r

This comment has been minimized.

Copy link
Owner

squ1b3r commented Nov 18, 2016

I don't really think something will change here until ST3 starts recognizing TM_COMMENT_MODE or adds something similar.

@chrisconlan

This comment has been minimized.

Copy link

chrisconlan commented Jun 11, 2018

I think the community needs a pared down version of this package that just handles syntax highlighting and common ST3 shortcuts like Ctrl+/. I'll start it.

https://github.com/ConlanHoldings/django-highlite

EDIT: I have updated this repository with parts of the Djaneiro repository that pertain to Django HTML. I don't plan to support Python Django snippets. I have also fixed the commenting issue.

@asfaltboy

This comment has been minimized.

Copy link

asfaltboy commented Aug 8, 2018

@chrisconlan can I use django-highlite alongside Djaneiro (for the python-django snippets) ?

@chrisconlan

This comment has been minimized.

Copy link

chrisconlan commented Aug 8, 2018

I haven't tried. If you include django-highlite after djaniero, my commenting shortcut might override the existing one and achieve your desired effect.

@asfaltboy

This comment has been minimized.

Copy link

asfaltboy commented Aug 8, 2018

It does work beautifully, thanks for making it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment