gc2gh / django-newsroom

Automatically exported from code.google.com/p/django-newsroom
Other
0 stars 0 forks source link

template tag to include media snippet #28

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
just wanted to write some notes about this, so opening an issue.

was watching adrian's talk at pycon on everyblock and just posting the idea
based on some of his code that describes a template tag that renders based
on the type of object ... dunno if it applies.

it's at 21:11 http://blip.tv/file/1957362

def render_media(mediaitem): 
    type = media_item.type 
    temp_names = ('snippets/%s.html' % type, 'snippets/default.html') 
    t = select_template(temp_names) 
    return t.render(template.Context({ 'mediaitem':mediaitem, })

render an object and select a custom template for it

they filter on an attribute called .schema as opposed to something we 
might have like .type  

basic idea is rendering based on an attribute in the db
  so snippets/video.html, snippets/audio.html, snippets/slideshow.html
  i.e 'snippets/%s.html' % multimedia.type

Original issue reported on code.google.com by mand...@gmail.com on 8 Apr 2009 at 2:53

GoogleCodeExporter commented 8 years ago
Should probably read this first ...

http://code.google.com/p/django-newsroom/wiki/MediaRFC

Original comment by mand...@gmail.com on 8 Apr 2009 at 4:34

GoogleCodeExporter commented 8 years ago

Original comment by jgty...@gmail.com on 13 Apr 2009 at 11:20

GoogleCodeExporter commented 8 years ago
Here's a very similar implementation from Jellyroll:
http://github.com/jacobian/jellyroll/blob/e1c10b15c1180479b631cf8cb456fe59a19998
ed/jellyroll/templatetags/jellyroll.py#L13-47

Original comment by pete.lin...@gmail.com on 19 May 2009 at 4:22