Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#648 closed defect (fixed)

[patch] Add a comment tag like {# commented #}

Reported by: hegemon Owned by: Adrian Holovaty
Component: Template system Version:
Severity: minor Keywords:
Cc: mccutchen@…, gary.wilson@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The default {% comment %} {% endcomment %} block is too much writing.

Attachments (2)

comment_tag.diff (2.3 KB ) - added by Hawkeye 18 years ago.
Patch to implement {# #} style comments
comment_syntax_with_tests.diff (3.6 KB ) - added by mccutchen@… 18 years ago.
New patch, including tests, against r3754

Download all attachments as: .zip

Change History (11)

comment:1 by Adrian Holovaty, 19 years ago

Resolution: wontfix
Status: newclosed

Two different types of syntax -- {% %} and {{ }} -- is already more than enough for our template system. We shall not go down a Perlish path! :)

comment:2 by django@…, 19 years ago

I think a {# balbalbla #} would be much nicer for comments then the unreadable and blowisch comment tag.
With those 3 types everything would be covered. With the current syntax for comments, i hardly doubt that people make comments at all, and if so, they are hard to read.

comment:3 by Adrian Holovaty, 18 years ago

Summary: Add a comment tag like {%# >>commented {{ code }}<< %}Add a comment tag like {# commented #}
Type: defect

comment:4 by Hawkeye, 18 years ago

Summary: Add a comment tag like {# commented #}[patch] Add a comment tag like {# commented #}

I think that this is a valuable proposal...

It will make code much more readable, and will encourage the use of comments...

{% if somecondition %}
foo
{% else %}{% comment %}not somecondition{% endcomment %}
bar
{% endif %}

is not readable, and I don't think it seems Django-ish... it's inelegant.

{% if somecondition %}
foo
{% else %} {# not somecondition #}
bar
{% endif %}

is much more readable

I'm uploading a patch for consideration.

by Hawkeye, 18 years ago

Attachment: comment_tag.diff added

Patch to implement {# #} style comments

comment:5 by mccutchen@…, 18 years ago

Cc: mccutchen@… added

I'm attaching a new diff that adds tests to the previous diff. This one was made from the root of django_src instead of from the django_src/tests/regressiontests/templates directory, it may be easier to apply.

I really think better comment syntax would be a boon to Django's template system.

by mccutchen@…, 18 years ago

New patch, including tests, against r3754

comment:6 by Chris Beaven, 18 years ago

See related ticket to allow block tags to be commented out: #2721

comment:7 by Gary Wilson <gary.wilson@…>, 18 years ago

Cc: gary.wilson@… added

I'm a fan of {# #} also.

comment:8 by django@…, 18 years ago

I'm totally fan of this (even implemented it half way on my sendbox, but forgott about it).
I think this patch increases the usage of comments a log, currenty, I rarly comment anything, because it makes the template even less readable. This is very problematic for complex templates. for example, i have some templates that generate .DOT and kml files, and have to make calculations to generate some values (no, the calculation is on the right place here, because i generates colors, length, etc out of numeric values). doing such things are very ugly in templates and hard to read anyways, without comments, outsiders can't do changes due a lack of understanding, at least they told me so :)

comment:9 by Adrian Holovaty, 18 years ago

Resolution: wontfixfixed

(In [3931]) Fixed #648 -- Added comment syntax to template system: {# #}. Thanks for the patch, mccutchen@… and Hawkeye

Note: See TracTickets for help on using tickets.
Back to Top