Change html attrs delimiter to --

This commit is contained in:
Matthew Tretter 2013-02-01 00:56:29 -05:00
parent 92b11f8349
commit 08ebcbcbf3
3 changed files with 15 additions and 15 deletions

View file

@ -10,7 +10,7 @@ register = template.Library()
ASSIGNMENT_DELIMETER = 'as'
HTML_ATTRS_DELIMITER = 'with'
HTML_ATTRS_DELIMITER = '--'
DEFAULT_THUMBNAIL_GENERATOR = 'ik:thumbnail'
@ -205,10 +205,10 @@ def generateimage(parser, token):
<img src="/path/to/34d944f200dd794bf1e6a7f37849f72b.jpg" width="100" height="100" />
You can add additional attributes to the tag using "with". For example,
You can add additional attributes to the tag using "--". For example,
this::
{% generateimage 'myapp:thumbnail' from=mymodel.profile_image with alt="Hello!" %}
{% generateimage 'myapp:thumbnail' from=mymodel.profile_image -- alt="Hello!" %}
will result in the following markup::
@ -250,7 +250,7 @@ def thumbnail(parser, token):
{% generateimage 'ik:thumbnail' from=mymodel.profile_image width=100 height=100 %}
The thumbnail tag supports the "with" and "as" bits for adding html
The thumbnail tag supports the "--" and "as" bits for adding html
attributes and assigning to a variable, respectively. It also accepts the
kwargs "anchor", and "crop".

View file

@ -14,25 +14,25 @@ def test_img_tag():
def test_img_tag_attrs():
ttag = r"""{% generateimage 'testspec' from=img with alt="Hello" %}"""
ttag = r"""{% generateimage 'testspec' from=img -- alt="Hello" %}"""
attrs = get_html_attrs(ttag)
eq_(attrs.get('alt'), 'Hello')
@raises(TemplateSyntaxError)
def test_dangling_with():
ttag = r"""{% generateimage 'testspec' from=img with %}"""
def test_dangling_html_attrs_delimiter():
ttag = r"""{% generateimage 'testspec' from=img -- %}"""
render_tag(ttag)
@raises(TemplateSyntaxError)
def test_with_assignment():
def test_html_attrs_assignment():
"""
You can either use generateimage as an assigment tag or specify html attrs,
but not both.
"""
ttag = r"""{% generateimage 'testspec' from=img with alt="Hello" as th %}"""
ttag = r"""{% generateimage 'testspec' from=img -- alt="Hello" as th %}"""
render_tag(ttag)
@ -41,7 +41,7 @@ def test_single_dimension_attr():
If you only provide one of width or height, the other should not be added.
"""
ttag = r"""{% generateimage 'testspec' from=img with width="50" %}"""
ttag = r"""{% generateimage 'testspec' from=img -- width="50" %}"""
attrs = get_html_attrs(ttag)
assert_not_in('height', attrs)

View file

@ -14,14 +14,14 @@ def test_img_tag():
def test_img_tag_attrs():
ttag = r"""{% thumbnail '100x100' img with alt="Hello" %}"""
ttag = r"""{% thumbnail '100x100' img -- alt="Hello" %}"""
attrs = get_html_attrs(ttag)
eq_(attrs.get('alt'), 'Hello')
@raises(TemplateSyntaxError)
def test_dangling_with():
ttag = r"""{% thumbnail '100x100' img with %}"""
def test_dangling_html_attrs_delimiter():
ttag = r"""{% thumbnail '100x100' img -- %}"""
render_tag(ttag)
@ -38,13 +38,13 @@ def test_too_many_args():
@raises(TemplateSyntaxError)
def test_with_assignment():
def test_html_attrs_assignment():
"""
You can either use thumbnail as an assigment tag or specify html attrs,
but not both.
"""
ttag = r"""{% thumbnail '100x100' img with alt="Hello" as th %}"""
ttag = r"""{% thumbnail '100x100' img -- alt="Hello" as th %}"""
render_tag(ttag)