(self, el, options, indent)
return code
Compile `t-if` expressions into a python code as a list of strings.

        The code will contain the condition `if`, `else` and `elif` part that
        wrap the rest of the compiled code of this element.
Compile `t-if` expressions into a python code as a list of strings.
Compile t - if expressions into a python code as a list of strings .
def _compile_directive_if(self, el, options, indent):
        """Compile `t-if` expressions into a python code as a list of strings.

        The code will contain the condition `if`, `else` and `elif` part that
        wrap the rest of the compiled code of this element.
        """
        if 't-elif' in el.attrib:
            expr = el.attrib.pop('t-elif')
        else:
            expr = el.attrib.pop('t-if')

        code = self._flushText(options, indent)
        content_if = self._compile_directives(el, options, indent + 1) + self._flushText(options, indent + 1)

        orelse = []
        next_el = el.getnext()
        comments_to_remove = []
        while isinstance(next_el, etree._Comment):
            comments_to_remove.append(next_el)
            next_el = next_el.getnext()
        if next_el is not None and {'t-else', 't-elif'} & set(next_el.attrib):
            parent = el.getparent()
            for comment in comments_to_remove:
                parent.remove(comment)
            if el.tail and not el.tail.isspace():
                raise ValueError("Unexpected non-whitespace characters between t-if and t-else directives")
            el.tail = None
            orelse = self._compile_node(next_el, dict(options, t_if=True), indent + 1) + self._flushText(options, indent + 1)

        code.append(self._indent(f"if {self._compile_expr(expr)}:", indent))
        code.extend(content_if or [self._indent('pass', indent + 1)])
        if orelse:
            code.append(self._indent("else:", indent))
            code.extend(orelse)
        return code
def _compile_directive_if ( self , el , options , indent ) : if 't-elif' in el . attrib : expr = el . attrib . pop ( 't-elif' ) else : expr = el . attrib . pop ( 't-if' ) code = self . _flushText ( options , indent ) content_if = self . _compile_directives ( el , options , indent + 1 ) + self . _flushText ( options , indent + 1 ) orelse = [ ] next_el = el . getnext ( ) comments_to_remove = [ ] while isinstance ( next_el , etree . _Comment ) : comments_to_remove . append ( next_el ) next_el = next_el . getnext ( ) if next_el is not None and { 't-else' , 't-elif' } & set ( next_el . attrib ) : parent = el . getparent ( ) for comment in comments_to_remove : parent . remove ( comment ) if el . tail and not el . tail . isspace ( ) : raise ValueError ( "Unexpected non-whitespace characters between t-if and t-else directives" ) el . tail = None orelse = self . _compile_node ( next_el , dict ( options , t_if = True ) , indent + 1 ) + self . _flushText ( options , indent + 1 ) code . append ( self . _indent ( f"if {self._compile_expr(expr)}:" , indent ) ) code . extend ( content_if or [ self . _indent ( 'pass' , indent + 1 ) ] ) if orelse : code . append ( self . _indent ( "else:" , indent ) ) code . extend ( orelse ) return code