'Return a list of tokens from a given template_string'

def tokenize(self):

    (result, upto) = ([], 0)
    for match in tag_re.finditer(self.template_string):
        (start, end) = match.span()
        if (start > upto):
            result.append(self.create_token(self.template_string[upto:start], (upto, start), False))
            upto = start
        result.append(self.create_token(self.template_string[start:end], (start, end), True))
        upto = end
    last_bit = self.template_string[upto:]
    if last_bit:
        result.append(self.create_token(last_bit, (upto, (upto + len(last_bit))), False))
    return result
