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
This commit is contained in:
Adrian Holovaty 2006-10-27 01:58:13 +00:00
parent ed27ff9aa9
commit 48234a0925
4 changed files with 12 additions and 2 deletions

View File

@ -106,7 +106,7 @@ answer newbie questions, and generally made Django that much better:
lakin.wecker@gmail.com lakin.wecker@gmail.com
Stuart Langridge <http://www.kryogenix.org/> Stuart Langridge <http://www.kryogenix.org/>
Eugene Lazutkin <http://lazutkin.com/blog/> Eugene Lazutkin <http://lazutkin.com/blog/>
Jeong-Min Lee Jeong-Min Lee <falsetru@gmail.com>
Christopher Lenz <http://www.cmlenz.net/> Christopher Lenz <http://www.cmlenz.net/>
lerouxb@gmail.com lerouxb@gmail.com
limodou limodou

View File

@ -1,7 +1,7 @@
"Default tags used by the template system, available to all templates." "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 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.template import get_library, Library, InvalidTemplateLibrary
from django.conf import settings from django.conf import settings
import sys import sys
@ -295,6 +295,8 @@ class TemplateTagNode(Node):
'closevariable': VARIABLE_TAG_END, 'closevariable': VARIABLE_TAG_END,
'openbrace': SINGLE_BRACE_START, 'openbrace': SINGLE_BRACE_START,
'closebrace': SINGLE_BRACE_END, 'closebrace': SINGLE_BRACE_END,
'opencomment': COMMENT_TAG_START,
'closecomment': COMMENT_TAG_END,
} }
def __init__(self, tagtype): def __init__(self, tagtype):
@ -831,6 +833,8 @@ def templatetag(parser, token):
``closevariable`` ``}}`` ``closevariable`` ``}}``
``openbrace`` ``{`` ``openbrace`` ``{``
``closebrace`` ``}`` ``closebrace`` ``}``
``opencomment`` ``{#``
``closecomment`` ``#}``
================== ======= ================== =======
""" """
bits = token.contents.split() bits = token.contents.split()

View File

@ -800,8 +800,12 @@ The argument tells which template bit to output:
``closevariable`` ``}}`` ``closevariable`` ``}}``
``openbrace`` ``{`` ``openbrace`` ``{``
``closebrace`` ``}`` ``closebrace`` ``}``
``opencomment`` ``{#``
``closecomment`` ``#}``
================== ======= ================== =======
Note: ``opencomment`` and ``closecomment`` are new in the Django development version.
widthratio widthratio
~~~~~~~~~~ ~~~~~~~~~~

View File

@ -552,6 +552,8 @@ class Templates(unittest.TestCase):
'templatetag08': ('{% templatetag closebrace %}', {}, '}'), 'templatetag08': ('{% templatetag closebrace %}', {}, '}'),
'templatetag09': ('{% templatetag openbrace %}{% templatetag openbrace %}', {}, '{{'), 'templatetag09': ('{% templatetag openbrace %}{% templatetag openbrace %}', {}, '{{'),
'templatetag10': ('{% templatetag closebrace %}{% templatetag closebrace %}', {}, '}}'), 'templatetag10': ('{% templatetag closebrace %}{% templatetag closebrace %}', {}, '}}'),
'templatetag11': ('{% templatetag opencomment %}', {}, '{#'),
'templatetag12': ('{% templatetag closecomment %}', {}, '#}'),
### WIDTHRATIO TAG ######################################################## ### WIDTHRATIO TAG ########################################################
'widthratio01': ('{% widthratio a b 0 %}', {'a':50,'b':100}, '0'), 'widthratio01': ('{% widthratio a b 0 %}', {'a':50,'b':100}, '0'),