Django

Code

Ticket #2016 (assigned)

Opened 4 years ago

Last modified 6 months ago

[patch] Decorator for template tags that load objects

Reported by: jason@pengale.com Assigned to: nobody (accepted)
Milestone: Component: Template system
Version: Keywords:
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 1
Needs tests: 1 Patch needs improvement: 1

Description

The django.template module includes two convenient decorators for making certain common template tags, simple_tag for inserting strings and inclusion_tag for including other templates. Another common idiom is loading an object into the template. For example:

{% get_recent_articles 4 as recent_articles %}

This patch includes an object_tag decorator that makes this kind of tag easy.

I'm new to Django and don't know how this fits in with the refactoring going on now, but I found it quite useful.

Attachments

object_tag.patch (1.7 kB) - added by jason@pengale.com on 05/26/06 21:08:26.
0001-Moves-the-argument-matching-to-a-separate-function.diff (1.1 kB) - added by marcusf on 09/15/09 04:53:50.
0002-Adds-the-object_tag-decorator.diff (1.7 kB) - added by marcusf on 09/15/09 04:54:06.
0003-Adds-documentation-for-object_tag.diff (2.1 kB) - added by marcusf on 09/15/09 04:54:24.
0004-Adds-tests-for-object_tag.diff (2.1 kB) - added by marcusf on 09/15/09 04:54:47.
object_tag-combined-patch.diff (6.8 kB) - added by marcusf on 09/15/09 10:17:11.
Following Alex's advice by providing a single patch file

Change History

05/26/06 21:08:26 changed by jason@pengale.com

  • attachment object_tag.patch added.

06/05/06 15:43:33 changed by adrian

  • status changed from new to assigned.

02/11/07 20:49:22 changed by SmileyChris

  • needs_tests set to 1.
  • stage changed from Unreviewed to Design decision needed.

Did Adrian's "assigned" means that this was approved?

02/11/07 20:49:37 changed by SmileyChris

  • needs_docs set to 1.
  • needs_tests deleted.

12/02/07 12:24:28 changed by jacob

  • needs_better_patch set to 1.
  • needs_tests set to 1.
  • stage changed from Design decision needed to Accepted.

09/15/09 04:53:50 changed by marcusf

  • attachment 0001-Moves-the-argument-matching-to-a-separate-function.diff added.

09/15/09 04:54:06 changed by marcusf

  • attachment 0002-Adds-the-object_tag-decorator.diff added.

09/15/09 04:54:24 changed by marcusf

  • attachment 0003-Adds-documentation-for-object_tag.diff added.

09/15/09 04:54:47 changed by marcusf

  • attachment 0004-Adds-tests-for-object_tag.diff added.

09/15/09 05:14:53 changed by marcusf

Added my own attempt to provide an improved patch along with documentation and tests.

09/15/09 10:04:22 changed by Alex

Please provide a single diff from the root of the source tree, rather than several files.

09/15/09 10:17:11 changed by marcusf

  • attachment object_tag-combined-patch.diff added.

Following Alex's advice by providing a single patch file

09/15/09 10:18:53 changed by marcusf

Sorry for the inconvenience, I've attached the new combined patch.


Add/Change #2016 ([patch] Decorator for template tags that load objects)




Change Properties
Action