'Finds all the Mako expressions in a Mako template and creates a list
of dicts for each expression.
Arguments:
mako_template: The content of the Mako template.
Returns:
A list of Expressions.'

def _find_mako_expressions(self, mako_template):

    start_delim = '${'
    start_index = 0
    expressions = []
    while True:
        start_index = mako_template.find(start_delim, start_index)
        if (start_index < 0):
            break
        uncommented_start_index = self._uncommented_start_index(mako_template, start_index)
        if (uncommented_start_index != start_index):
            start_index = uncommented_start_index
            continue
        result = self._find_closing_char_index(start_delim, '{', '}', mako_template, start_index=(start_index + len(start_delim)))
        if (result is None):
            expression = Expression(start_index)
            start_index = (start_index + len(start_delim))
        else:
            close_char_index = result['close_char_index']
            expression = mako_template[start_index:(close_char_index + 1)]
            expression = Expression(start_index, end_index=(close_char_index + 1), template=mako_template, start_delim=start_delim, end_delim='}', strings=result['strings'])
            start_index = expression.end_index
        expressions.append(expression)
    return expressions
