AI OnAI Off
I have found that looking for a parent action view context provides me with a way to tell level 0 items apart from the rest.
I guess this works because my page controller is rendering level 0 content areas and this is the first action method to be invoked. Once the rendering starts crawling down into block content areas, it will call additional block controller action methods to render the block views. When this happens, the parent page controller action/view context is stored in ParentActionViewContext.
I am not sure that the above description applies for partial views though.
The solution to my challenge was to append "htmlHelper.ViewContext?.ParentActionViewContext == null" to my if condition for whether to return a css class value.
I need to conditionally return an item css class in my custom content area renderer depending on whether a content area item is in the first content area encountered as opposed to subsequent items belonging to content areas further down the content area item parent-child tree. Is there a renderer context or similar that I can check to get the "level" that I'm at?
An example hierarchy is frontpage content area -> tab block -> content area -> rich text block. Only the tab block should have its display option css class output by GetContentAreaItemCssClass(...). I need to differentiate between the tab block item and rich text block item. Or am I going about this wrong?