def do_get_text_image(parser, token):
    """
    To use presets from settings.CAIROTEXT_PRESETS['base_params'] and
    override text color, use:

    {% get_text_image "Text" color "#aaa" font "Sans" height 20 as img %}
    <img src="{{img.url}}" width="{{img.width}}" height="{{img.height}}" />
    """
    bits = token.split_contents()
    count = len(bits)
    if count < 4:
        raise TemplateSyntaxError('%r expects at least 3 arguments')
    if bits[-2] != 'as':
        raise TemplateSyntaxError('%r expects "as" as its '
                                  'second last argument')
    text = parser.compile_filter(bits[1])
    base_params = None
    if count % 2:
        base_params = parser.compile_filter(bits[2])
    overrides = dict((keyword, compile(parser, value))
                     for keyword, value in zip(bits[2+count%2:-2:2], bits[3+count%2:-2:2]))
    varname = bits[-1]

    unknown_keywords = set(overrides.keys()).difference(PARAM_KEYWORDS)
    if unknown_keywords:
        raise TemplateSyntaxError('%r got unknown keywords %s' % (
                bits[0],
                ', '.join(unknown_keywords)))
    return GetTextImageNode(base_params, text, overrides, varname)
dataset/ETHPy150Open akaihola/django-cairo-text/cairotext/templatetags/cairotext.py/do_get_text_image/original