In an attempt to make a hiearchical menu structured from JSON data with an unknown depth, I tried creating a partial that referenced itself. I hadn’t seen it documented so I wasn’t expecting anything to happen. To my surprise, it worked.
The only problem is, I noticed that performance tanks in some browsers. For example, in Safari, the first time going to this example seems to take a while to display. On some occassions it doesn’t do anything. In certain older versions of Chrome, it would take over a minute to display the list.
I really like being able to use partials this way. My concern is that performance issues won’t allow me to use this in production.
I’ve built a few nested templates…and I ran into the same performance issues that you’re running into.
In my case, I didn’t need to show the entire node tree when the page first loaded…each level was, by default, collapsed which sped up the rendering performance (it’s rendering much less after all!). I did this by including a isCollapsed property on the itemController …then, the template would look like: