
import ast

from .library import Library

register = Library()


@register.tag(name='block')
def block(parser, token):
    token = token.strip()
    parser.build_method(token, endnodes=['endblock'])
    return ast.YieldFrom(
        value=ast.Call(
            func=ast.Attribute(
                value=ast.Name(id='self', ctx=ast.Load()),
                attr=token,
                ctx=ast.Load()
            ),
            args=[
                ast.Name(id='context', ctx=ast.Load()),
            ],
            keywords=[], starargs=None, kwargs=None
        )
    )


@register.tag(name='if')
def do_if(parser, token):
    code = ast.parse(token, mode='eval')

    nodelist = list(parser.parse_node(['endif']))

    return ast.IfExp(test=code.body, body=nodelist)


@register.tag(name='else')
def do_else(parser, token=None):
    return ast.Yield(value=ast.Str(s=''))

@@ -196,32 +196,47 @@
 k'%5D)%0A    return 
+ast.Expr(value=
 ast.YieldFrom(%0A 
@@ -580,16 +580,17 @@
  )%0A    )
+)
 %0A%0A%0A@regi
@@ -745,19 +745,16 @@
 n ast.If
-Exp
 (test=co
@@ -846,24 +846,39 @@
 %0A    return 
+ast.Expr(value=
 ast.Yield(va
@@ -895,9 +895,10 @@
 r(s=''))
+)
 %0A

Use ast.If not ast.IfExp for if tag