Opened 18 years ago
Closed 13 years ago
#3624 closed New feature (fixed)
Syndication could be friendlier to non Django templating languages
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.syndication | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | treborhudson@… | Triage Stage: | Someday/Maybe |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
To specify the title or description for a feed, the syndication module will accept a path to a template:
"You can also change the names of these two templates by specifying title_template and description_template as attributes of your Feed class."
http://www.djangoproject.com/documentation/syndication/
This makes it a little unfriendly to non Django templating languages since it will use the loader defined in Django. It would be nice if it took a template object and rendered that, as opposed to using a string, using the default Django loader and rendering the template. This would allow me to easily use my templating language in my feed module, without interfering with the underlying module.
Django-0.95.1
contrib/syndication/feeds.py:
try:
description_tmp = loader.get_template(self.description_template_name)
except TemplateDoesNotExist:
description_tmp = Template('{{ obj }}')
Attachments (3)
Change History (12)
comment:1 by , 18 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:2 by , 17 years ago
Cc: | added |
---|---|
Component: | Uncategorized → Contrib apps |
Owner: | changed from | to
Version: | 0.95 → 0.96 |
by , 17 years ago
Attachment: | feeds.diff added |
---|
Patch against trunk. I can add docs if this looks good.
by , 17 years ago
Attachment: | feeds.2.diff added |
---|
Cleaned up, tested override and default, and added docs.
comment:3 by , 17 years ago
Triage Stage: | Design decision needed → Someday/Maybe |
---|
by , 16 years ago
Attachment: | item_title_and_description_methods.patch added |
---|
Another approach to solve that problem.
comment:4 by , 16 years ago
The previous patch takes a slightly different approach than the two patches already submitted. In fact, it takes the same approach as the other syndication fields: item_title() and item_description() methods are responsible for fetching the content of both fields, and by default it will fetch a template or use {{ obj }}. Thus, one is free to override those to use its own templating or to just provide the value without having to use a template.
I think this is fine since often, those method would just be:
def item_title(self, item): return item.title def item_description(self, item): return item.contents
Note that the current patch doesn't include docs, and that the "current_site" argument for the template has been lost in the process. It can be reintroduced though.
comment:5 by , 16 years ago
This would help me, personally, in the case of syndication feeds on the new comment model. The unicode() function in comments makes the title of each comment into the first 50 words of the comment itself. I'd prefer to override that in the feed (akin to the old 0.96 behaviour of "By <author> on <date>" instead.
comment:6 by , 16 years ago
Version: | 0.96 → 1.0 |
---|
comment:7 by , 14 years ago
Component: | Contrib apps → contrib.syndication |
---|
comment:8 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:9 by , 13 years ago
Easy pickings: | unset |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Version: | 1.0 → SVN |
The methods described above were added with changeset r12338, which moved syndication to class-based views. This means that anyone who wants to use an alternate template language can just override the method and do whatever they want.
Or similar to the feed title and description, have the ability for the subclass to create methods of "item_title" or "item_description". I created a patch that will allow the user to add these methods that return a Template object.