Problem/Motivation
Proposed resolution
Remaining tasks
User interface changes
API changes
During the DrupalCon Amsterdam discussion about page rendering, we decided that the following steps are necessary to fix #2327277: [Meta] Page rendering meta discussion:
Critical
- Remove
HtmlFragment
&HtmlPage
, but make sure that'#type' => 'page'
works (because controllers should be able to return entire pages, without having the content be surrounded by blocks) — see #2352155: Remove HtmlFragment/HtmlPage - Prevent crazy asset handling and crazy page manipulation:
- For the valid use cases of adding content to the page, we introduce
hook_page_top()
andhook_page_bottom()
: for adding content to the very top or bottom of the page (not regions!) — see #2350949: Add hook_page_attachments(_alter)() and deprecate hook_page_build/alter() - Introduce
hook_page_attachments()
, which may be implemented by both modules and themes, to allow assets to be added to pages conditionally. For assets unconditionally added to pages by themes,hook_preprocess_page()
must be used. We keephook_page_build()
around, for backwards compatibility — but we only allow assets to be added — see #2350949: Add hook_page_attachments(_alter)() and deprecate hook_page_build/alter()
- For the valid use cases of adding content to the page, we introduce
- Document how to attach assets correctly:
- Allow preprocess functions to cleanly attach assets for the associated template — see #2346369: Support special '#attached' variable for attaching assets in preprocess functions
- Documentation:
hook_page_attachments()
to conditionally attach assets to pages,hook_preprocess_page()
to unconditionally attach assets to pages — see #2350949: Add hook_page_attachments(_alter)() and deprecate hook_page_build/alter()
- Remove
drupal_add_html_head()
,drupal_add_html_head_link()
anddrupal_add_feed()
, accept['#attached']['head']
,['#attached']['head_link']
,['#attached']['feed']
instead — see #2350877: Deprecate/rename drupal_add_feed(), drupal_add_html_head(), drupal_add_html_head_link(), drupal_add_http_header(), and allow to be set declaratively in #attached
Nice-to-have
- Convert all
page
template (page.html.twig
) variables to blocks - Extract
RenderableInterface extends CacheableInterface
fromBlockPluginInterface
. Begin with just abuild()
method that returns a render array, during D8 cycle, gradually add more methods so that the render array doesn't contain asset metadata anymore, etc. — until nothing remains, at which point we'll have done a lot of the work of moving away from the Render ArrayPI.