Last active
July 30, 2021 07:20
-
-
Save hazho/d333b8fed243de9e07eb4fe52afd5d13 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import template | |
from django.utils.safestring import mark_safe | |
register = template.Library() | |
@register.filter(needs_autoescape=True) | |
def replace(value, arg, autoescape=True): | |
if arg == "[but]": result = value.replace(arg, "<button style='font-size:1.5rem; padding: .5rem; margin: .25rem; text-align: center; box-shadow: 0 0 .5rem blue;'>") | |
if arg == "[s.5]": result = value.replace(arg, "<span style='font-size: .5rem !important;'>") | |
if arg == "[s1]": result = value.replace(arg, "<span style='font-size:1rem !important;'>") | |
elif arg == "[s1.2]": result = value.replace(arg, "<span style='font-size:1.2rem !important;'>") | |
elif arg == "[s1.4]": result = value.replace(arg, "<span style='font-size:1.4rem !important;'>") | |
elif arg == "[s1.6]": result = value.replace(arg, "<span style='font-size:1.6rem !important;'>") | |
elif arg == "[s1.8]": result = value.replace(arg, "<span style='font-size:1.8rem !important;'>") | |
elif arg == "[s2]": result = value.replace(arg, "<span style='font-size:2rem !important;'>") | |
elif arg == "[s2.2]": result = value.replace(arg, "<span style='font-size:2.2rem !important;'>") | |
elif arg == "[s2.4]": result = value.replace(arg, "<span style='font-size:2.4rem !important;'>") | |
elif arg == "[s2.6]": result = value.replace(arg, "<span style='font-size:2.6rem !important;'>") | |
elif arg == "[s2.8]": result = value.replace(arg, "<span style='font-size:2.8rem !important;'>") | |
elif arg == "[s3]": result = value.replace(arg, "<span style='font-size:3rem !important;'>") | |
elif arg == "[s3.2]": result = value.replace(arg, "<span style='font-size:3.2rem !important;'>") | |
elif arg == "[s3.4]": result = value.replace(arg, "<span style='font-size:3.4rem !important;'>") | |
elif arg == "[s3.6]": result = value.replace(arg, "<span style='font-size:3.6rem !important;'>") | |
elif arg == "[s3.8]": result = value.replace(arg, "<span style='font-size:3.8rem !important;'>") | |
elif arg == "[s4]": result = value.replace(arg, "<span style='font-size:4rem !important;'>") | |
elif arg == "[s4.2]": result = value.replace(arg, "<span style='font-size:4.2rem !important;'>") | |
elif arg == "[s4.4]": result = value.replace(arg, "<span style='font-size:4.4rem !important;'>") | |
elif arg == "[s4.6]": result = value.replace(arg, "<span style='font-size:4.6rem !important;'>") | |
elif arg == "[s4.8]": result = value.replace(arg, "<span style='font-size:4.8rem !important;'>") | |
elif arg == "[s5]": result = value.replace(arg, "<span style='font-size:5rem !important;'>") | |
elif arg == "[s5.2]": result = value.replace(arg, "<span style='font-size:5.2rem !important;'>") | |
elif arg == "[s5.4]": result = value.replace(arg, "<span style='font-size:5.4rem !important;'>") | |
elif arg == "[s5.6]": result = value.replace(arg, "<span style='font-size:5.6rem !important;'>") | |
elif arg == "[s5.8]": result = value.replace(arg, "<span style='font-size:5.8rem !important;'>") | |
elif arg == "[s6]": result = value.replace(arg, "<span style='font-size:6rem !important;'>") | |
elif arg == "[s6.2]": result = value.replace(arg, "<span style='font-size:6.2rem !important;'>") | |
elif arg == "[s6.4]": result = value.replace(arg, "<span style='font-size:6.4rem !important;'>") | |
elif arg == "[s6.6]": result = value.replace(arg, "<span style='font-size:6.6rem !important;'>") | |
elif arg == "[s6.8]": result = value.replace(arg, "<span style='font-size:6.8rem !important;'>") | |
elif arg == "[s7]": result = value.replace(arg, "<span style='font-size:7rem !important;'>") | |
elif arg == "[r]": result = value.replace(arg, "<span style='color: red !important;'>") | |
elif arg == "[dr]": result = value.replace(arg, "<span style='color: darkred !important;'>") | |
elif arg == "[g]": result = value.replace(arg, "<span style='color: green !important;'>") | |
elif arg == "[dg]": result = value.replace(arg, "<span style='color: darkgreen !important;'>") | |
elif arg == "[b]": result = value.replace(arg, "<span style='color: blue !important;'>") | |
elif arg == "[db]": result = value.replace(arg, "<span style='color: darkblue !important;'>") | |
elif arg == "[p]": result = value.replace(arg, "<span style='color: purple !important;'>") | |
elif arg == "[dp]": result = value.replace(arg, "<span style='color: darkpurple !important;'>") | |
elif arg == "[y]": result = value.replace(arg, "<span style='color: yellow !important;'>") | |
elif arg == "[dy]": result = value.replace(arg, "<span style='color: darkyellow !important;'>") | |
elif arg == "[]": result = value.replace(arg, "<span style='color: var(--main_color) !important;'>") | |
elif arg == "[sp]": result = value.replace(arg, " ") | |
elif arg == "[nl]": result = value.replace(arg, "<br>") | |
return mark_safe(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment