from collections import OrderedDict


def _template(inlist):
    """
    Return an OrderedDict with templates


    >>> list(_template(['MNI152NLin2009c']).keys())
    ['MNI152NLin2009c']

    >>> _template(['MNI152NLin2009c', 'MNI152NLin2009c:res-2'])
    OrderedDict([('MNI152NLin2009c', {})])

    >>> _template(['MNI152NLin2009c', 'MNI152NLin2009c:res-2',
    ...            'MNI152NLin6Asym:res-2', 'MNI152NLin6Asym'])
    OrderedDict([('MNI152NLin2009c', {}), ('MNI152NLin6Asym', {'res': '2'})])

    """
    if isinstance(inlist, str):
        inlist = [inlist]

    templates = []
    for item in reversed(inlist):
        item = item.split(':')
        tpl_arg = (item[0], {})
        for i in item[1:]:
            modifier = i.split('-', 1)
            tpl_arg[1][modifier[0]] = modifier[1] if len(modifier) == 2 else None
        templates.append(tpl_arg)

    return OrderedDict(reversed(OrderedDict(templates).items()))