From 48234a0925fcba67a72d3cfc31fbf66cca3f2e33 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Fri, 27 Oct 2006 01:58:13 +0000 Subject: [PATCH] Fixed #2961 -- Added 'opencomment' and 'closecomment' options to {% templatetag %} templatetag. Thanks for the patch, Jeong-Min Lee git-svn-id: http://code.djangoproject.com/svn/django/trunk@3938 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- AUTHORS | 2 +- django/template/defaulttags.py | 6 +++++- docs/templates.txt | 4 ++++ tests/regressiontests/templates/tests.py | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index 52d4950e4e..83eaa63927 100644 --- a/AUTHORS +++ b/AUTHORS @@ -106,7 +106,7 @@ answer newbie questions, and generally made Django that much better: lakin.wecker@gmail.com Stuart Langridge Eugene Lazutkin - Jeong-Min Lee + Jeong-Min Lee Christopher Lenz lerouxb@gmail.com limodou diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py index 07e579bf9d..6144267c1a 100644 --- a/django/template/defaulttags.py +++ b/django/template/defaulttags.py @@ -1,7 +1,7 @@ "Default tags used by the template system, available to all templates." from django.template import Node, NodeList, Template, Context, resolve_variable -from django.template import TemplateSyntaxError, VariableDoesNotExist, BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END, SINGLE_BRACE_START, SINGLE_BRACE_END +from django.template import TemplateSyntaxError, VariableDoesNotExist, BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END, SINGLE_BRACE_START, SINGLE_BRACE_END, COMMENT_TAG_START, COMMENT_TAG_END from django.template import get_library, Library, InvalidTemplateLibrary from django.conf import settings import sys @@ -295,6 +295,8 @@ class TemplateTagNode(Node): 'closevariable': VARIABLE_TAG_END, 'openbrace': SINGLE_BRACE_START, 'closebrace': SINGLE_BRACE_END, + 'opencomment': COMMENT_TAG_START, + 'closecomment': COMMENT_TAG_END, } def __init__(self, tagtype): @@ -831,6 +833,8 @@ def templatetag(parser, token): ``closevariable`` ``}}`` ``openbrace`` ``{`` ``closebrace`` ``}`` + ``opencomment`` ``{#`` + ``closecomment`` ``#}`` ================== ======= """ bits = token.contents.split() diff --git a/docs/templates.txt b/docs/templates.txt index 0f0009b495..92d4b53660 100644 --- a/docs/templates.txt +++ b/docs/templates.txt @@ -800,8 +800,12 @@ The argument tells which template bit to output: ``closevariable`` ``}}`` ``openbrace`` ``{`` ``closebrace`` ``}`` + ``opencomment`` ``{#`` + ``closecomment`` ``#}`` ================== ======= +Note: ``opencomment`` and ``closecomment`` are new in the Django development version. + widthratio ~~~~~~~~~~ diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py index ef31b853ca..bcb9c66254 100644 --- a/tests/regressiontests/templates/tests.py +++ b/tests/regressiontests/templates/tests.py @@ -552,6 +552,8 @@ class Templates(unittest.TestCase): 'templatetag08': ('{% templatetag closebrace %}', {}, '}'), 'templatetag09': ('{% templatetag openbrace %}{% templatetag openbrace %}', {}, '{{'), 'templatetag10': ('{% templatetag closebrace %}{% templatetag closebrace %}', {}, '}}'), + 'templatetag11': ('{% templatetag opencomment %}', {}, '{#'), + 'templatetag12': ('{% templatetag closecomment %}', {}, '#}'), ### WIDTHRATIO TAG ######################################################## 'widthratio01': ('{% widthratio a b 0 %}', {'a':50,'b':100}, '0'),