Commits

Shlomi Fish  committed 6a3f1c8

Remove the separators in the JSON.

This way the jqTree rendering routines won't be confused.

  • Participants
  • Parent commits f19bfee
  • Branches convert-from-jquery-treeview-to-jqtree-plugin

Comments (0)

Files changed (1)

File lib/MyNavData.pm

         },
     );
 
-    return encode_json($params{tree_contents});
+    my $filter_out_seperators;
+
+    $filter_out_seperators = sub {
+        my ($sub_tree) = @_;
+
+        my @keys = (grep { $_ ne 'subs' } keys %{$sub_tree});
+
+        my $has_subs = exists($sub_tree->{subs});
+
+        return {
+            (map { $_ => $sub_tree->{$_} } @keys),
+            $has_subs
+            ?  (subs => [ map { $filter_out_seperators->($_) }
+                    grep { ! exists($_->{separator}) }
+                    @{$sub_tree->{subs}}
+                ])
+            : (),
+        },
+    };
+
+    return encode_json($filter_out_seperators->($params{tree_contents}));
 }
 
 1;