stages/email: start rewriting templates, add template tags to embed CSS and images

This commit is contained in:
Jens Langhammer
2020-05-10 20:16:58 +02:00
parent e989c61793
commit a67c53f46a
15 changed files with 499 additions and 276 deletions

View File

@ -1,20 +0,0 @@
"""passbook core inlining template tags"""
import os
from django import template
from django.conf import settings
register = template.Library()
@register.simple_tag()
def inline_static(path):
"""Inline static asset. If file is binary, return b64 representation"""
prefix = "data:image/svg+xml;utf8,"
data = ""
full_path = settings.STATIC_ROOT + "/" + path
if os.path.exists(full_path):
if full_path.endswith(".svg"):
with open(full_path) as _file:
data = _file.read()
return prefix + data