add templatetags library
This commit is contained in:
parent
efd11240d0
commit
53d5a38f63
0
itf/emailer/templatetags/__init__.py
Normal file
0
itf/emailer/templatetags/__init__.py
Normal file
16
itf/emailer/templatetags/emailer.py
Normal file
16
itf/emailer/templatetags/emailer.py
Normal 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)
|
Loading…
Reference in New Issue
Block a user