def apply_instantiation(tpl,format_dict):
    """Apply instantiation of a template (or a struct containing template strings)

    keywords
    tpl         -- the template
    format_dict -- value replacement for keys
    """
    if isinstance(tpl,dict):
        instance={}
        for k,v in tpl.items():
            instance[k]=apply_instantiation(v,format_dict)
        return instance
    elif isinstance(tpl,list):
        instance=[]
        for e in tpl:
            instance.append(apply_instantiation(e,format_dict))
        return instance
    elif isinstance(tpl,str):
        return tpl.format_map(format_dict)
    else:
        return tpl