Commit Graph

70 Commits

Author SHA1 Message Date
Jacob Kaplan-Moss bd2b0059be Here's the rest of [9530] where I actually rename the tag like I said I did. I swear this was git's fault, not mine.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9532 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-11-24 22:33:32 +00:00
Jacob Kaplan-Moss 4aa97f5c18 Fixed #6398: added an optional `{% empty %}` clause to the `{% for %}` template tag. The contents of this clause are rendered if the list iterated over turns out to be empty. Thanks, Jannis Leidel.
Astute readers will notice that the patch originally called this `default`; after consideration I decided that `empty` is a very slightly better color for this particular bikeshed.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9530 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-11-24 22:01:48 +00:00
Malcolm Tredinnick 8fb1459b52 Added some better error reporting and path handling when creating template paths.
We now raise UnicodeDecodeError for non-UTF-8 bytestrings (thanks to Daniel
Pope for diagnosing this was being swallowed by ValueError) and allow UTF-8
bytestrings as template directories.

Refs #8965.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@9161 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-10-06 06:34:54 +00:00
Malcolm Tredinnick 7838493b9e Fixed #8726 -- When doing reverse URL resolving, make sure we're consistently
dealing with unicode strings throughout by promoting up from UTF-8 as necessary.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8777 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-31 22:47:25 +00:00
Jacob Kaplan-Moss 86316f0be6 Fixed #7027: template tags now corectly break tokens around strings marked for translation.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8769 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-31 18:28:06 +00:00
Malcolm Tredinnick 6390155f5c Added a couple of extra tests to ensure url tag robustness. These are an
attempt to verify #8726.

Refs #8726.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8766 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-31 17:29:49 +00:00
Malcolm Tredinnick a63a83e5d8 A rewrite of the reverse URL parsing: the reverse() call and the "url" template tag.
This is fully backwards compatible, but it fixes a bunch of little bugs. Thanks
to SmileyChris and Ilya Semenov for some early patches in this area that were
incorporated into this change.

Fixed #2977, #4915, #6934, #7206.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8760 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-31 11:11:20 +00:00
Jacob Kaplan-Moss f2d7ee759a Fixed #8710: removed a few stray tabs. Thanks, gkelly.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8746 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-30 19:25:40 +00:00
Jacob Kaplan-Moss c068bc184c Merge branch 'url-tag-asvar'
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8716 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-29 19:28:03 +00:00
Malcolm Tredinnick c46bb219bf Fixed #7460 -- Made the "cache" template tag always generate keys that can be
used with the memcache backend (which has the strongest restriction on keys).
Based on a patch from trbs.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8533 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-25 04:52:55 +00:00
Gary Wilson Jr 6d863fef8a Fixed #5270 -- Allow template tags and filters to accept an emtpy string, patch from jdunck.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8393 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-15 21:08:11 +00:00
Luke Plant c768bc6f25 Fixed #8031 - url tag no longer silences NoReverseMatch exceptions since this is very rarely useful
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8211 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-05 14:16:13 +00:00
Malcolm Tredinnick e29aece743 Fixed #4534 -- Added an "else" option to the "ifchanged" template tag.
Patch from SmileyChris.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8095 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-26 22:09:43 +00:00
Adrian Holovaty 74f0408fa2 Fixed #6201 -- Improved the {% cache %} template tag to allow the timeout to be a template variable. Inspired by the patch by zz and edrik
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7754 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-26 04:54:10 +00:00
Adrian Holovaty 5ee4a099f1 Fixed infuriating lack of apostrophe in a comment
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7753 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-26 04:33:18 +00:00
Adrian Holovaty dbde7fc8b0 Fixed #6322 -- Fixed bug in 'ifchanged' template tag where it wasn't resetting itself properly in some cases. Thanks, nedbatchelder
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7752 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-26 04:30:06 +00:00
Adrian Holovaty 65437a95e1 Improved our tests so that they don't raise an error if setuptools isn't installed, hence ridding the test suite of all dependencies. Also updated docs.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7751 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-26 04:25:40 +00:00
Russell Keith-Magee 4317ba5799 Fixed #7318 -- Cleaned up the template inheritance logic, specifically to handle the case where the parent template has no template tags/blocks. Took the opportunity to optimize the logic a little. Thanks to Matthias Kestenholz <mk@spinlock.ch> for the original report and test case.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7688 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-18 12:59:39 +00:00
Russell Keith-Magee d53e8f1285 Fixed #6430 -- Corrected the loading of templates from eggs, which was broken by the unicode merge. Thanks for the excellent report and patch, Juan Manuel Caicedo <juan.manuel.caicedo@gmail.com>.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7565 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-05-29 13:11:23 +00:00
Malcolm Tredinnick d18a114f86 Fixed #6326 -- Made the test for translations of filter arguments test something that has a chance of failure. Thanks akaihola.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7060 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-03 01:49:55 +00:00
Adrian Holovaty 3d52ce730f Reverted 'regroup' template tag changes from [6956], as they caused bug #6271, which affects one of my sites. I don't have time to inspect the #6271 patch, so I'm reverting this change in the interim, to fix the bug immediately.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6996 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-01-05 00:03:12 +00:00
Adrian Holovaty 293f0f2360 Fixed #6295 -- Made the {% for %} tag a bit more efficient by creating a single context dictionary rather than recreating it each time through the loop. Thanks, Ned Batchelder
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6981 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-01-02 05:01:03 +00:00
Gary Wilson Jr d1b5a0bde5 Removed some reverse string craziness from the regroup template tag argument checking and added a few syntax tests.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6956 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-12-19 06:11:55 +00:00
Malcolm Tredinnick 67373009e0 Fixed #4563 -- Context.pop/push/update return the top-level dictionary (the new
one for push() and update(), the one removed for pop()). Based on a patch from
Brian Harring.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6854 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-12-02 23:57:22 +00:00
Malcolm Tredinnick 3c272792d6 Added tests and a small optimisation for [6721]. Thanks SmileyChris. Fixed #6049
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6729 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-11-29 01:44:30 +00:00
Malcolm Tredinnick 9130765ff9 Fixed #5890 -- fixed the far edge-case of allowing constant strings inside
template template markers: we now treat embedded, escaped double quotes
consistently with constant string arguments to filters. Patch from Dmitri
Fedortchenko.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6724 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-11-28 21:04:05 +00:00
Malcolm Tredinnick 5f8cfe99f3 Fixed #5969 -- Corrected a problem introduced in [6682].
*sigh* As usual, the one case I forget to test turned out to be broken.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6689 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-11-18 03:36:03 +00:00
Malcolm Tredinnick adcec0885d Fixed a few problems with variable resolving inside of blocktrans tags. A couple of these were exposed by the auto-escaping changes, but I suspect the other one has been hiding in plain sight for a while.
Fixed #5952, #5953


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6682 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-11-17 12:12:18 +00:00
Malcolm Tredinnick 0928fa5566 Fixed #5945 -- Treat string literals in template filter arguments as safe
strings for auto-escaping purposes.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6680 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-11-17 12:11:26 +00:00
Malcolm Tredinnick 0b0ef3f0c5 Fixed #4713 -- Fixed handling of _() in template tag arguments. Based on
patched from Indy and SmileyChris.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6679 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-11-17 04:04:12 +00:00
Malcolm Tredinnick bdb0b903c2 Content coming via {{ block.super }} is always going to be correctly escaped
already. We mark it as safe so that template authors don't need to.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6673 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-11-14 21:07:27 +00:00
Malcolm Tredinnick 356662cf74 Implemented auto-escaping of variable output in templates. Fully controllable by template authors and it's possible to write filters and templates that simulataneously work in both auto-escaped and non-auto-escaped environments if you need to. Fixed #2359
See documentation in templates.txt and templates_python.txt for how everything
works.

Backwards incompatible if you're inserting raw HTML output via template variables.

Based on an original design from Simon Willison and with debugging help from Michael Radziej.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6671 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-11-14 12:58:53 +00:00
Malcolm Tredinnick 7ca708140a Fixed #2920 -- Removed _() from builtins.
This is backwards incompatible, but easy to work around.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6582 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-21 17:14:25 +00:00
Malcolm Tredinnick 6fbf653aa5 Fixed #1065 -- Added a "cache" template tag. Thanks, Ian Maurer and, particularly, Nick Lane.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6580 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-21 15:48:40 +00:00
Malcolm Tredinnick b678601df3 Fixed #4123 -- Changed the firstof template tag to correctly handle a literal
string as its last argument. Thanks, Wesley Fok and Matt Boersma.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6571 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-20 15:01:31 +00:00
Gary Wilson Jr 66203fc9ee Fixed #2675 -- Changed the `timeuntil` and `timesince` template filters to display "0 minutes" when passed a past or future date respectively instead of "-1 years, 12 months". Thanks to nickefford for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6366 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-09-17 04:50:12 +00:00
Russell Keith-Magee 09145d2e5f Fixed #208 -- Modernized the syntax of the cycle tag to allow for spaces and variables in cycle values. Thanks to SmileyChris and Chris McAvoy for their work on this.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6153 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-09-14 02:49:21 +00:00
Gary Wilson Jr 304381616f Fixed #4952 -- Fixed the `get_template_sources` functions of the `app_directories` and `filesystem` template loaders to not return paths outside of given template directories. Both functions now make use of a new `safe_join` utility function. Thanks to SmileyChris for help with the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5750 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-23 04:45:01 +00:00
Russell Keith-Magee 73bec372ee Fixed #4897 -- Fixed minor typo in doctest comment.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5728 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-20 12:15:02 +00:00
Malcolm Tredinnick 8c85ddf306 Fixed #4772 -- Fixed reverse URL creation to work with non-ASCII arguments.
Also included a test for non-ASCII strings in URL patterns, although that
already worked correctly.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5630 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-07 18:24:27 +00:00
Malcolm Tredinnick 953badbea5 Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.

Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 12:11:04 +00:00
Jacob Kaplan-Moss 24512a74be Fixed #1465: added support for regex lookups. Thanks, Tom Tobin.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5555 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-06-27 18:58:10 +00:00
Malcolm Tredinnick a5802b35dd Fixed #4453 -- Allow dots in URL pattern names (although the string in that case is first tried as an import path and only then falls back to being treated as a pattern).
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5530 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-06-25 04:34:34 +00:00
Russell Keith-Magee 16269c4d0a Fixed #3523 -- Added list unpacking to for loops in templates. Thanks to SmileyChris and Honza Kral for their work.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5443 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-06-08 11:58:03 +00:00
Malcolm Tredinnick faa31732ca Fixed #3753 -- Allow optional display of invalid variable name in
TEMPLATE_STRING_IF_INVALID. Thanks, Matt McClanahan.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5167 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-05-08 03:36:16 +00:00
Malcolm Tredinnick d9f1a0aaef Renamed one test to avoid a name-clash with an earlier test of the same name.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5125 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-04-28 16:41:44 +00:00
Malcolm Tredinnick 54f11ee63c Fixed #4164, #4171 -- Reworked some of the template lexer logic to ensure we
don't get caught out by a couple of corner cases.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5104 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-04-27 12:16:22 +00:00
Malcolm Tredinnick 6fe5235cea Renamed filter template tests to be in their own sequence. Makes it easier to
add tests if the related names aren't spread out across creation.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5103 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-04-27 11:01:45 +00:00
Malcolm Tredinnick aa1b182da3 Fixed #3543 -- Be a bit more tolerant of spaces following the comma
argument separator in the "url" tag.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5077 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-04-25 10:29:39 +00:00
Malcolm Tredinnick 2a512a4e83 Fixed #3749 -- Set the context correctly when using the "filter" template tag.
Thanks, Zak Johnson.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5052 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-04-21 04:44:30 +00:00