Forked from linville/country_code_to_emoji_extras.py
Created
October 21, 2016 19:59
-
-
Save sammachin/7cf1c361e84bb3098e39926ca0f87477 to your computer and use it in GitHub Desktop.
Django template converts country code to Emoji
This file contains 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 | |
register = template.Library() | |
OFFSET = ord('🇦') - ord('A') | |
@register.filter | |
def flag(code): | |
return chr(ord(code[0]) + OFFSET) + chr(ord(code[1]) + OFFSET) | |
# Example: | |
# flag("US") = "🇺🇸" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment