I notice in Drupal source code, in core modules hook_theme()
, some places are 'render element' => 'element'
and some places are 'render element' => 'elements'
(plural). Why? Even the render element purpose is to display a single object (e.g. node canonical), not a list of objects.
The problem is it results in different key in $variables
in template_preprocess_hook()
. For instance, I have a custom entity and if I use _entity_view
in entity canonical route, the $variables
has 'elements'
. But if I manually use this entity theme in a page, the $variables
has 'element'
. I'm so confused.