1. storborg
  2. WebHelpers


pjenvey  committed b545296

[svn] deprecate image_tag automatically appending '.png' to sources with no extension
(Sync'd to 4999)

  • Participants
  • Parent commits 4b947c5
  • Branches trunk

Comments (0)

Files changed (2)

File tests/test_asset_tag.py

View file
  • Ignore whitespace
     def test_image_tag(self):
         self.assertEqual('<img alt="Xml" src="/images/xml.png" />',
-                         image_tag('xml'))
+                         image_tag('xml.png'))
         self.assertEqual('<img alt="rss syndication" src="/images/rss.png" />',
-                        image_tag('rss', alt='rss syndication'))
+                        image_tag('rss.png', alt='rss syndication'))
         self.assertEqual('<img alt="Gold" height="70" src="/images/gold.png" width="45" />',
-                         image_tag('gold', size='45x70'))
-        self.assertEqual('<img alt="Symbolize" height="70" src="/images/symbolize.png" width="45" />',
-                         image_tag('symbolize', size='45x70'))
+                         image_tag('gold.png', size='45x70'))
+        self.assertEqual('<img alt="Symbolize" height="70" src="/images/symbolize.jpg" width="45" />',
+                         image_tag('symbolize.jpg', size='45x70'))
         self.assertEqual('<img alt="Pylons-Tower-Dark1" src="http://pylons.tgtg.org/powered/_img/pylons-tower-dark1.png" />',

File webhelpers/rails/asset_tag.py

View file
  • Ignore whitespace
 Provides functionality for linking an HTML page together with other assets, such as
 javascripts, stylesheets, and feeds.
-# Last synced with Rails copy at Revision 4103 on Aug 19th, 2006.
+# Last synced with Rails copy at Revision 4999 on Sep 6th, 2006.
 import os
 import urlparse
+import warnings
 from tags import *
 from routes import request_config
         The source URL of the image. The URL is prepended with '/images/', unless its full
         path is specified. The URL is ultimately prepended with the environment's
         ``SCRIPT_NAME`` (the root path of the web application), unless the URL is
-        fully-fledged (e.g. http://example.com). A source with no filename extension will
-        be automatically appended with the '.png' extension.
+        fully-fledged (e.g. http://example.com).
         The img's alt tag. Defaults to the source's filename, title cased.
-        >>> image_tag('xml')
+        >>> image_tag('xml.png')
         '<img alt="Xml" src="/images/xml.png" />'
-        >>> image_tag('rss', 'rss syndication')
+        >>> image_tag('rss.png', 'rss syndication')
         '<img alt="rss syndication" src="/images/rss.png" />'    
+    if not os.path.splitext(source)[1]:
+        warnings.warn("You've called image_tag with a source that doesn't include an "
+                      "extension. Soon image_tag will no longer automatically append "
+                      "'.png' to your source. Please call image_path('%s.png') instead" % \
+                      source, DeprecationWarning, 2)
     options['src'] = compute_public_path(source, 'images', 'png')
     if not alt: