Obtain template name from data, allowing for nested attributes
function getTemplateName(data) {
        for (var i = 0; i < templateAttribute.length; ++i) {
            if (!data) return null;
            data = data[templateAttribute[i]];
        }
        return data;
    }