def get_param(name, dictionary):
    """Retrieves the parameter dictionary[name] or dictionary["templates_dict"][name]
    
    Raises:
        KeyError
    """
    if ("templates_dict" in dictionary):
        dictionary = dictionary["templates_dict"]
    if (name in dictionary):
        return dictionary[name]
    raise KeyError("'{}' was not found in context.".format(name))