Hi, I'm using the inline-app from Django-Basic-Apps for inserting images in Blogposts. But in some templates I don't want the images to appear. It's not enough to just not render them, I don't even want the inline-code to be in the html. Is there a way to delete the inline-code with a filter? I tried to use the "|cut" filter, but its just not flexible enough. I guess I would have to write my own templatetag to take care of this, but I'm quite new to Python and Django and don't now how that works.
A:
If anybody's interested, here is my solution:
@register.filter
def del_inlines(value):
soup = BeautifulStoneSoup(value, selfClosingTags=['inline'])
inlines = soup.findAll('inline')
[inline.extract() for inline in inlines]
return soup
BeautifulSoup is just great!
Jacques Knie
2010-10-27 09:51:05