17 lines
443 B
Python
17 lines
443 B
Python
|
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)
|