private static function exportNestedDataForTemplates(array $array, $root = true)
    {
        // depth first
        foreach ($array as $prop => &$value) {
            if (is_array($value)) {
                $value = self::exportNestedDataForTemplates($value, false);
            }
        }
        unset($value);
        // json data expected to be keyed with ints, over the usual strings
        if (isset($array[0])) {
            // replace array with exportable array list
            $array = new ArrayListExportable($array);
        }
        return $root ? var_export($array, true) : $array;
    }