add templatetags library

This commit is contained in:
Sanj 2012-01-18 16:23:35 +05:30
parent efd11240d0
commit 53d5a38f63
2 changed files with 16 additions and 0 deletions

View File

View File

@ -0,0 +1,16 @@
from django import template
import re
from emailer.models import *
register = template.Library()
def insert_images(value, article_id):
regex = 'img\:(.*?)\r?\n'
article = EmailerArticle.objects.get(id=article_id)
matches = re.findall(regex, value)
for m in matches:
imgHTML = article.getImageHTML(m)
value = value.replace("img:" + m, imgHTML)
return value
register.filter('insert_images', insert_images)