def METHOD_NAME(self):
    state = self.State.TEXT
    # Process template source
    while self.cursor < len(self.source):
        # Process plain text till first token occurance
        if state == self.State.TEXT:
            if self.source[self.cursor :].startswith("{%"):
                state = self.State.CONTROL
                self.cursor += 1
            elif self.source[self.cursor :].startswith("{{"):
                state = self.State.VARIABLE
                self.cursor += 1
            else:
                self.block += self.source[self.cursor]
            # Commit self.block if token was found
            if state != self.State.TEXT:
                self.processText()
        elif state == self.State.CONTROL:
            if self.source[self.cursor :].startswith("%}"):
                self.cursor += 1
                state = self.State.TEXT
                self.processControl()
            else:
                self.block += self.source[self.cursor]
        elif state == self.State.VARIABLE:
            if self.source[self.cursor :].startswith("}}"):
                self.cursor += 1
                state = self.State.TEXT
                self.processVariable()
            else:
                self.block += self.source[self.cursor]
        else:
            raise Exception("Unknown State")
        self.cursor += 1
    if state != self.State.TEXT:
        raise Exception("Last self.block was not closed")
    if self.block:
        self.processText()
    return "\n".join(self.blocks)