'Returns the rendered string as an iterator.
Replaces template placeholders with keyword arguments (if any).
Replaces source code with the return value of eval() or exec().'

def _render(self, compiled, *args, **kwargs):

    k = {}
    for d in args:
        k.update(d)
    k.update(kwargs)
    k['template'] = template
    indent = kwargs.pop('indent', False)
    for (cmd, v, w) in compiled:
        if (indent is False):
            w = ''
        if (cmd is None):
            continue
        elif (cmd == '<str>'):
            (yield self._encode(v, w))
        elif (cmd == '<arg>'):
            (yield self._encode(k.get(v, ('$' + v)), w))
        elif (cmd == '<if>'):
            (yield (''.join(self._render(v[1], k)) if eval(v[0]) else ''))
        elif (cmd == '<for>'):
            (yield ''.join([''.join(self._render(v[2], k, self._dict(v[0], i))) for i in eval(v[1], k)]))
        elif (cmd == '<eval>'):
            (yield self._encode(eval(v, k), w))
        elif (cmd == '<exec>'):
            o = StringIO()
            k['write'] = o.write
            exec v in k
            (yield self._encode(o.getvalue(), w))
            del k['write']
            o.close()
