smores.utils

get_module_schemas

get_module_schemas(module_)

Returns list of all classes found in the module_

Arguments:

module_ (module): where to find schemas

Returns:

list: schemas found in module_

loop_table_rows

loop_table_rows(iterable_tags, template_string)

A template preprocessing function that enables a special way of iterating over values in a list of objects. It searches for table cells with particular tags and wraps the table row (and subsequent rows if they also contain the tags) with a jinja for loop using the iterator, iterable tuple from 'iterable_tags' Example:

Arguments:

iterable_tags (dict): mapping of
template_string (str): jinja template string

Returns:

string: transformed template string

Example:

iterable_tags = {
    "mydogs.*": ("mydogs", "user.dogs")
}

input = '''
    <table>
        <tr>
            <td>{mydogs.name}</td>
        </tr>
        <tr>
            <td>{mydogs.weight}</td>
        </tr>
    </table>
'''

>>> smores.utils.loop_table_rows(input)
<table>
    {% for mydogs in user.dogs %}
        <tr>
            <td>{mydogs.name}</td>
        </tr>
        <tr>
            <td>{mydogs.weight}</td>
        </tr>
    {% endfor %}
</table>