The docs for renderable arrays - https://drupal.org/node/930760 define #markup as:

The simplest property, this simply provides a markup string for #type => 'markup'

But, as per #2012818: Remove #type 'markup' this is both inaccurate and vague about what's really going on.

A better description of what #markup does, and this is *by design* according to @tim.plunkett, so we should update the docs accordingly:

"#markup defines a string of raw HTML that will be prepended to the rendered children of this renderable array, before #theme_wrappers are called, but only if #theme is not set. If #markup is set and #type is not set then #type will be set to 'markup' to ensure any relevant defaults are loaded from element_info()."

The reason for this is that #markup is intended as a fallback/default when there is no theme implementation available to process the renderable array.

The guiding principle here is that if #theme is set then it is theme()'s responsibility to render the array 100% so we should be clearer in the docs what falls in this "100%" and what doesn't - eg., pre_prender, post_render, prefix, suffix

As well as the d.o docs needing updates, there is no mention of #markup in the docblock of the drupal_render() function itself so we should add a paragraph there explaining its intended usage.

Comments

jhodgdon’s picture

Status: Active » Postponed (maintainer needs more info)

Is this a core API documentation issue? It seems to be pointing to a documentation page on api.drupal.org. In which case you can:
a) just edit the page and fix it (preferable)
b) move this issue to the Documentation project issue queue.

thedavidmeister’s picture

Status: Postponed (maintainer needs more info) » Active

there is no mention of #markup in the docblock of the drupal_render() function itself so we should add a paragraph there explaining its intended usage.

jhodgdon’s picture

Title: The documentation for #markup in renderable arrays is misleading. » drupal_render() docs do not mention #markup and should
Issue tags: +Novice

OK, good point. So the drupal_render() documentation currently says:

If #theme is not present and the element has children, each child is itself rendered by a call to drupal_render(), and the results are concatenated.

We need it to also say here that if there is a #markup property, that is concatenated as well (before the children). I'm sure there's a concise and precise/accurate way to say that. Seems like a good Novice project.

As for the on-line documentation you mentioned in the original issue here, please either file an issue in the Documentation project about that, or (preferably) edit the page and fix it. Thanks!

And note that this is Drupal 8.x only. The 7.x drupal_render() does *not* do this at all.

thedavidmeister’s picture

If #theme is not present and the element has children, each child is itself rendered by a call to drupal_render(), and the results are concatenated.

That's actually not quite true. It's currently "If #theme returns an empty value", which can happen when #theme is present but not a hook that has been implemented, like suggestions provided by the Form API.

See #2012812: drupal_render() can't distinguish between empty strings from theme() and no hook being matched.

jhodgdon’s picture

Actually, it's even more complicated than that, sigh. In 8.x, the sequence is:
- #children is set to '' if it was unset prior to the call to drupal_render().
- If #theme is set and #render_children is not, set #children to the output of theme(), using #theme as the theme hook. [Note: theme() returns an empty string if the theme hook is not matched.]
- if #children is still identical to '', render the children and concatenate them; store the result in #children.
- if #theme is not set and #markup is, prepend #markup to #children.

Sigh. I'm not sure how to write that out in clear concise prose... but we may not need every technicality to get into the documentation. I think the basic idea is that if #theme hasn't been defined or the theme hook hasn't been implemented, #markup and the rendered children are concatenated as the default output.

thedavidmeister’s picture

Issue tags: -Novice

Sigh. I'm not sure how to write that out in clear concise prose...

The whole #markup thing is cray, check out failing tests in https://drupal.org/node/2012818#comment-7515983

I think the basic idea is that if #theme hasn't been defined or the theme hook hasn't been implemented, #markup and the rendered children are concatenated as the default output.

Yeah, that's about it - where that description falls down has already been filed as a bug with a patch waiting for review. This is fine, the main potential for weirdness in the behaviour of #markup comes from the way #type 'markup' is merged in so I think that's really important to document. The #markup attribute sets a #type of 'markup' too if it isn't already set, regardless of whether #theme being set precludes #markup from being used to render markup.

This leads to:

array A: array('#theme' => 'foo', '#markup' => 'bar');

array B: array('#type' => 'foo', '#markup' => 'bar);

Assuming that element_info() does not define #theme = #type by default for 'foo', which is a common enough situation.

Renderable array A in HEAD will have its #type set to 'markup' (as #type is not set) but #markup will not be rendered.

Renderable array B in HEAD will have its #type left as 'foo' but #markup will be rendered.

For somebody trying to implement hook_element_info_alter() for 'markup', it would be good to know a little bit about how the #type for markup is merged in.

jhodgdon’s picture

Title: drupal_render() docs do not mention #markup and should » drupal_render() docs do not mention #markup, setting default type to markup, or adding defaults to elements.

I'm not sure exactly what you're saying in #6...

It's true that if #type is not set, and #markup is, then #type is set to "markup" in drupal_render(). And this happens before the defaults are added from hook_element_info() for the #type. That should be mentioned if it isn't already in the documentation... and it isn't... actually the documentation doesn't even say that defaults are added from hook_element_info(), and it should.

It's also true that defaults for many elements set #theme; however, in Drupal 8, there is no default #theme for markup elements. So I don't think we need to worry about this in our discussion of #markup.

This is becoming "not a novice"... Oh I see you already removed that tag. Good!

Care to make a patch?

thedavidmeister’s picture

no, I was saying that #markup sets #type to 'markup' for elements that have an unrelated #theme set, despite the fact that #theme being set means that #markup probably won't be rendered. That's the bit that's weird - I don't know if we have to explicitly spell that out but we need to be clear that #type 'markup' is merged in as a default unconditionally when #markup is set so somebody has a chance to realise that the defaults from #type 'markup' will be there whether or not #markup is used in the final render without poking through the code of drupal_render().

Anyway, I'm happy to make a patch. Not today though, but I'm watching this issue so I'll get to it sooner or later if nobody else does.

jhodgdon’s picture

In Drupal 8, setting the type to 'markup' really doesn't do anything, since system_element_info() doesn't add a pre-render or anything else there. So I don't think you really need to worry about it.

And just as a note, #type is never overridden -- it is only set to 'markup' if it wasn't set previously.

So... Let's just document that:
- Elements without #type are set to type 'markup' if #markup is set.
- All elements have defaults from hook_element_info() added to them before any other processing.
- The main rendering step is normally done by calling theme() with the theme hook given in #theme.
- If #theme hasn't been defined or the theme hook hasn't been implemented, #markup and the rendered children are concatenated as the main rendering step output.

Maybe some clarification between the terminology of "element" vs. "renderable array" is also needed?

thedavidmeister’s picture

That all sounds good to me.

thedavidmeister’s picture

jhodgdon’s picture

RE #11...
- In light of the first issue, we should now say that ... well I'm not sure because I don't quite understand what that issue does (it needs a change notice).
- In light of the second issue, we should not now say that #type is set to '#markup' if it is omitted. I guess that items without a #type are OK.

thedavidmeister’s picture

Items without a #type are fine currently, there's lots of render arrays in core that just have #theme set and no #type.

The first issue actually implements/enforces what you described earlier:

- If #theme hasn't been defined or the theme hook hasn't been implemented, #markup and the rendered children are concatenated as the main rendering step output.

Previously there was no check to see if the #theme hook is actually implemented before trying to use the fallback/inline method of rendering children, it simply assumed that empty string = no theme hook implemented (but that could have also just meant that the theme hook *was* implemented but intended to render that element as an empty string).

thedavidmeister’s picture

Title: drupal_render() docs do not mention #markup, setting default type to markup, or adding defaults to elements. » drupal_render() docs do not mention most of the base # attributes, adding default attributes to elements or how rendering works
Status: Active » Needs review

What about this, we just explain what actually happens in the code in plain English:

The process of rendering each element is as follows:
  - If this element has already been printed (#printed = TRUE) or the user does
    not have access to it (#access = FALSE) then an empty string is returned.
  - If this element has #cache defined then the cached markup for this element
    will be returned if it exists in drupal_render()'s cache.
  - If this element has #type defined and the defaults attributes for this
    element have not already been merged in (#defaults_loaded = TRUE) then the
    defaults for this type of element, defined in hook_element_info() are merged
    into the array.
  - If this element has an array of #pre_render functions defined, they are
    called sequentially to modify the element before rendering.
  - The main render phase to produce #children for this element takes place.
    - If #theme is defined and is an implemented theme hook/suggestion then
      theme() is called and must render both the element and its children.
    - If #theme is not implemented and #children is empty then drupal_render()
      is called recursively on each of the child elements of this element and
      the result of each is concatenated onto #children.
    - In the special case that #render_children is set drupal_render() will
      recursively render child elements even if #theme is an implemented theme
      hook, i.e. theme() will be bypassed.
    - Once #children has been rendered, if #theme is not an implemented and
      #markup is set for this element, #markup will be prepended to #children.
  - Any additional JavaScript, CSS or custom data is added to this elemnet.
  - If an array of #theme_wrappers is set and #render_children is not set then
    #children is re-rendered by passing the element in its current state to
    theme() for each item in #theme_wrappers.
  - If this element has an array of #post_render functions defined, they are
    called sequentially to modify the rendered #children.
  - If #prefix and/or #suffix are set, they are concatenated to #children.
  - The final value of #children is returned as the rendered output.
jhodgdon’s picture

Status: Needs review » Needs work

What a concept! I like the idea of #14.

Let's see if I like the details... I think it's mostly good, but I have a few suggestions:

a) I am not sure I would refer to "this element", since the input is $elements. Maybe it would be OK if there was an explanation that it refers to the outermost array of $elements at the beginning?

b) Third bullet point:

If this element has #type defined and the defaults attributes for this element have not already been merged in (#defaults_loaded = TRUE) then the defaults for this type of element, defined in hook_element_info() are merged into the array.

- "defaults attributes" should be "default attributes"
- missing comma after hook_element_info()
- you might want to note that #defaults_loaded is then set to TRUE so that the defaults are not merged again? ... or ... when/where does this actually happen? hmmm.

c) After #pre_render, #printed is checked again, which isn't in your list.

d) Detail: #theme is only used if #render_children is not set:

 if ($theme_is_implemented && !isset($elements['#render_children'])) {
 

Oh I see you mention this later on... I would mention it in each bullet point where it's relevant rather than getting to it later on.

e) Detail: drupal_render() is called on children either if #render_children is set or there wasn't a #theme or theme() returned FALSE indicating there was no theme function/template:

 if ((!$theme_is_implemented || isset($elements['#render_children'])) && empty($elements['#children'])) {

I also think I would mention that #children could have been set by pre-render or theme() at this point.

f) Typo in the #markup bullet point "if #theme is not an implemented" (remove "an").

g) In post_render, you might mention that #children is passed in, as opposed to many of the other steps, when $element is passed in as a whole.

h) At the end you might mention that #printed is set and that the result is cached if #cache is set.

thedavidmeister’s picture

Status: Needs work » Needs review
The process of rendering each element is as follows:
  - If this element has already been printed (#printed = TRUE) or the user does
    not have access to it (#access = FALSE) then an empty string is returned.
  - If this element has #cache defined then the cached markup for this element
    will be returned if it exists in drupal_render()'s cache.
  - If this element has #type defined and the default attributes for this
    element have not already been merged in (#defaults_loaded = TRUE) then the
    defaults for this type of element, defined in hook_element_info(), are
    merged into the array. #defaults_loaded is set by functions that process
    render arrays and call element_info() before passing the array to
    drupal_render(), such as form_builder() in the FAPI.
  - If this element has an array of #pre_render functions defined, they are
    called sequentially to modify the element before rendering. After all the
    #pre_render functions have been called, #printed is checked a second time
    in case a #pre_render function flags the element as printed.
  - The main render phase to produce #children for this element takes place.
    - If #theme is defined and is an implemented theme hook/suggestion then
      theme() is called and must render both the element and its children. If
      #render_children is set theme() will not be called.
    - If #theme is not implemented and #children is empty then drupal_render()
      is called recursively on each of the child elements of this element and
      the result of each is concatenated onto #children.
    - In the special case that #render_children is set drupal_render() will
      recursively render child elements even if #theme is an implemented theme
      hook, i.e. theme() will be bypassed.
    - Once #children has been rendered, if #theme is not implemented and
      #markup is set for this element, #markup will be prepended to #children.
  - Any additional JavaScript, CSS or custom data is added to this elemnet.
  - If an array of #theme_wrappers is set and #render_children is not set then
    #children is re-rendered by passing the element in its current state to
    theme() for each item in #theme_wrappers.
  - If this element has an array of #post_render functions defined, they are
    called sequentially to modify the rendered #children. Unlike #pre_render
    functions, #post_render functions are passed both the rendered #children
    attribute as a string and the render array.
  - If #prefix and/or #suffix are set, they are concatenated to #children.
  - If #cache is set the rendered output of this element is saved to
    drupal_render()'s internal cache.
  - #printed is set to TRUE to ensure this element is only rendered once.
  - The final value of #children is returned as the rendered output.

Here's an update.

Not sure about point A though, I thought drupal_render() always acts on a single array element (the outermost one) and $elements (plural) is referring to the fact that this element may have children - which are processed recursively, but each one is rendered individually as "an element" by drupal_render(). theme() can process multiple elements at once, but that's a different function.

star-szr’s picture

I'm liking the way this is heading :)

- Any additional JavaScript, CSS or custom data is added to this elemnet.

Typo on element.

@thedavidmeister, your last paragraph in #16 might be a good candidate for a docs addition as well!

jhodgdon’s picture

Status: Needs review » Needs work

I think the documentation should not start out by referring to "each element" though. drupal_render renders one single $elements array (recursively, but still each time it is called, it is only dealing with one element really). When you say "each element", it sounds to me like a for loop.

I guess this is a problem with the existing drupal_render documentation...

Let's see.

What if the documentation read:

First line:
Renders a structured renderable array into HTML.

Then skip the next line in the current doc... and continue with this paragraph, which I think we still need:

 * Renderable arrays have two kinds of key/value pairs: properties and
 * children. Properties have keys starting with '#' and their values influence
 * how the array will be rendered. Children are all elements whose keys do not
 * start with a '#'. Their values should be renderable arrays themselves,
 * which will be rendered during the rendering of the parent array. The markup
 * provided by the children is typically inserted into the markup generated by
 * the parent array.

And then skip all the rest of what's there (up to the param/return section) and replace with:

The process of rendering an element is recursive. During each call to drupal_render(), the outermost renderable array (also known as an "element") is processed using the following steps:
[your list from #16]

I think the list in #16 of steps is looking pretty good. A few minor grammar/style/etc. cleanups to do:
- Typo mentioned in #17
- Don't say "FAPI" without defining what it is. Say "Form API" (3rd bullet point)
- Every list (or sub-list) needs to be preceded by a : -- so the 5th bullet point should end in "...element takes place:".
- i.e. and e.g. are almost always confused, almost always used wrong, and almost always punctuated wrong (as they are here). So I advise everyone to avoid them in drupal API docs... In the "special case" sub-list bullet point, can we say instead of "...even if #theme is an implemented theme hook, i.e. theme() will be bypassed." ==> "...implemented theme hook; that is, theme() will be bypassed."
- Some of the bullet points use grammatical structure like "If this element has an array of #post_render functions defined" or "If this element has #type defined ", whereas others have structure like "If #theme is defined". Can we make them all have the same grammatical structure? Pick one... I don't have a strong preference; both seem clear enough to me.

thedavidmeister’s picture

Status: Needs work » Needs review
Renders HTML given a structured array tree.

Renderable arrays have two kinds of key/value pairs: properties and children.
Properties have keys starting with '#' and their values influence how the array
will be rendered. Children are all elements whose keys do not start with a '#'.
Their values should be renderable arrays themselves, which will be rendered
during the rendering of the parent array. The markup provided by the children is
typically inserted into the markup generated by the parent array.

The process of rendering an element is recursive unless the element defines an
implemented theme hook in #theme. During each call to drupal_render(), the
outermost renderable array (also known as an "element") is processed using the
following steps:
  - If this element has already been printed (#printed = TRUE) or the user does
    not have access to it (#access = FALSE) then an empty string is returned.
  - If this element has #cache defined then the cached markup for this element
    will be returned if it exists in drupal_render()'s cache. To use
    drupal_render() caching, set the element's #cache property to an associative
    array with one or several of the following keys:
    - 'keys': An array of one or more keys that identify the element. If 'keys'
      is set, the cache ID is created automatically from these keys. See
      drupal_render_cid_create().
   - 'granularity' (optional): Define the cache granularity using binary
      combinations of the cache granularity constants, e.g.
      DRUPAL_CACHE_PER_USER to cache for each user separately or
      DRUPAL_CACHE_PER_PAGE | DRUPAL_CACHE_PER_ROLE to cache separately for each
      page and role. If not specified the element is cached globally for each
      theme and language.
    - 'cid': Specify the cache ID directly. Either 'keys' or 'cid' is required.
      If 'cid' is set, 'keys' and 'granularity' are ignored. Use only if you
      have special requirements.
    - 'expire': Set to one of the cache lifetime constants.
    - 'bin': Specify a cache bin to cache the element in. Defaults to 'cache'.
  - If this element has #type defined and the default attributes for this
    element have not already been merged in (#defaults_loaded = TRUE) then the
    defaults for this type of element, defined in hook_element_info(), are
    merged into the array. #defaults_loaded is set by functions that process
    render arrays and call element_info() before passing the array to
    drupal_render(), such as form_builder() in the Form API.
  - If this element has an array of #pre_render functions defined, they are
    called sequentially to modify the element before rendering. After all the
    #pre_render functions have been called, #printed is checked a second time
    in case a #pre_render function flags the element as printed.
  - The child elements of this element are sorted by weight using uasort() in
    element_children(). Since this is expensive, when passing already sorted
    elements to drupal_render(), for example from a database query, set
    $elements['#sorted'] = TRUE to avoid sorting them a second time.
  - The main render phase to produce #children for this element takes place:
    - If this element has #theme defined and #theme is an implemented theme
      hook/suggestion then theme() is called and must render both the element
      and its children. If #render_children is set theme() will not be called.
    - If this element does not have a defined #theme or the defined #theme hook
      is not implemented and #children is empty then drupal_render() is called
      recursively on each of the child elements of this element and the result
      of each is concatenated onto #children.
    - If this element has #render_children set and #children is empty
      drupal_render() will recursively render child elements. In this case, even
      if #theme is an implemented theme hook, theme() will be bypassed.
    - Once #children has been rendered for this element, if #theme is not
      implemented and #markup is set for this element, #markup will be prepended
      to #children.
  - Any additional JavaScript, CSS or custom data is added to this element.
  - If this element has an array of #theme_wrappers defined and #render_children
    is not set then #children is re-rendered by passing the element in its
    current state to theme() successively for each item in #theme_wrappers.
  - If this element has an array of #post_render functions defined, they are
    called sequentially to modify the rendered #children. Unlike #pre_render
    functions, #post_render functions are passed both the rendered #children
    attribute as a string and the render array.
  - If this element has #prefix and/or #suffix defined, they are concatenated to
    #children.
  - If this element has #cache defined the rendered output of this element is
    saved to drupal_render()'s internal cache.
  - #printed is set to TRUE for this element to ensure that it is only rendered
    once.
  - The final value of #children for this element is returned as the rendered
    output.

@param array $elements
  The structured array describing the data to be rendered.

@return string
  The rendered HTML.

How's this? I tried to clean up the points from #18 and #17 and incorporate the existing docs so we can see it all together.

jhodgdon’s picture

Status: Needs review » Needs work

Wow, this is looking really good!

Just a couple of minor things I noticed:

a)

   - If this element has #theme defined and #theme is an implemented theme
      hook/suggestion then theme() is called and must render both the element
      and its children. If #render_children is set theme() will not be called.
    - If this element does not have a defined #theme or the defined #theme hook
      is not implemented and #children is empty then drupal_render() is called
      recursively on each of the child elements of this element and the result
      of each is concatenated onto #children.
    - If this element has #render_children set and #children is empty
      drupal_render() will recursively render child elements. In this case, even
      if #theme is an implemented theme hook, theme() will be bypassed.

This is still kind of hard to follow. The third bullet point here seems to be kind of redundant... Can we just say in the second bullet point perhaps:

   - If this element does not have a defined #theme, or the defined #theme hook
      is not implemented, or #render_children is set,  then drupal_render() is called
      recursively on each of the child elements of this element and the result
      of each is concatenated onto #children. This is skipped if #children is not empty at this point.

And leave out the third bullet?

b)

 - If this element has an array of #post_render functions defined, they are
    called sequentially to modify the rendered #children. Unlike #pre_render
    functions, #post_render functions are passed both the rendered #children
    attribute as a string and the render array.

At the very end I think we should say "element" instead of "render array"? The rest of the text refers to $elements as "the element".

Let's have a patch and get this in! Vast improvement over what was in drupal_render() previously.

thedavidmeister’s picture

Status: Needs work » Needs review
StatusFileSize
new9.7 KB

How about this?

I tried to address #20 and I added a bit more information about what #render_children actually even is.

meeli’s picture

Some minor readability points:

If #render_children is set theme() will not be called.

should have a comma after "set": "If #render_children is set, theme() will not be called."

If this element does not have a defined #theme, or the defined #theme hook is not implemented, or #render_children is set,  then drupal_render() is called recursively on each of the child elements of this element and the result of each is concatenated onto #children. This is skipped if #children is not empty at this point.

There's a double space after "set," and before "then drupal_render()...". Needs to be a single space.

If this element has an array of #theme_wrappers defined and #render_children is not set then #children is re-rendered by passing the element in its current state to theme() successively for each item in #theme_wrappers.

I'd rewrite this run-on sentence by replacing "then" with a comma: "If this element has an array of #theme_wrappers defined and #render_children is not set, #children is then re-rendered by passing the element in its current state to theme() successively for each item in #theme_wrappers."

If this element has #cache defined the rendered output of this element is saved to drupal_render()'s internal cache.

Same deal here, needs a comma after "defined".

thedavidmeister’s picture

StatusFileSize
new9.7 KB
new2.33 KB

Changes attached.

jhodgdon’s picture

I read through the entire patch, and I think this is in very good shape...

The only question I had was in this line near the bottom:

+ *   - Any additional JavaScript, CSS or custom data is added to this element.

Do we need to mention here what #properties are used to do this, in order to satisfy the current issue title's part "do not mention most of the base # attributes"? Or at least what function or functions are called to do this? Also, there should be a comma before "or" in this line.

thedavidmeister’s picture

Status: Needs review » Needs work

sure

thedavidmeister’s picture

Status: Needs work » Needs review
StatusFileSize
new1.25 KB
new10.22 KB

Updated as per #24 to document both the attributes and called functions of drupal_render() better.

jhodgdon’s picture

then any required libraries,
+ *     JavaScript, CSS or other custom data

Any time there is a list with "and" or "or", our style standards require a serial comma before and/or.

In fact, I think you could also use commas in several other places:

+ *     - If this element does not have a defined #theme, or the defined #theme
+ *       hook is not implemented, or #render_children is set, then
+ *       drupal_render() is called recursively on each of the child elements of
+ *       this element and the result of each is concatenated onto #children.

(before the last "and"

+ *   - If this element has already been printed (#printed = TRUE) or the user
+ *     does not have access to it (#access = FALSE) then an empty string is
+ *     returned.

(before "then")

etc.

But if we're just quibbling over commas, this is pretty good... I think the whole thing overall reads very well and I'd be willing to commit it as-is, although I'd prefer a few more commas.

thedavidmeister’s picture

StatusFileSize
new10.22 KB
new1.84 KB

Updates as per #27.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Great! Let's get this one in once the bot says "go". :)

Thanks for your hurculean effort on this, David!!!

jhodgdon’s picture

Version: 8.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Thank you again!!!!!!!!!!

I have committed this to 8.x. I think we should backport this change to 7.x. This is probably not just a straight reroll of the patch -- we need to read through the code to drupal_render() in 7.x and take out/alter any sections that do not apply to 7.x.

thedavidmeister’s picture

Yeah, I'm much less familiar with the inner workings of drupal_render() in D7 - I'm not sure that I'm the best person to follow up on the backport..

jhodgdon’s picture

Actually I do not think the code is all that different. Just needs someone to read through this patched documentation vs. the D7 code and take out or modify the things that aren't correct.

jhodgdon’s picture

Issue summary: View changes

Updated issue summary.

valentine94’s picture

Issue summary: View changes
Status: Patch (to be ported) » Needs review
StatusFileSize
new6.56 KB

Back-port for D7.

jhodgdon’s picture

Version: 7.x-dev » 8.0.x-dev
Status: Needs review » Needs work

Um... This patch doesn't look right to me. Why did you indent the cache section list? It was indented right before. And now the part about "If this element has an array of #pre_render functions defined..." is part of the caching list?

So this needs some work. The thing to do is probably to start over and go to Drupal 8 and copy the entire doc block for drupal_render(), and paste it into Drupal 7's doc block. Then remove or rewrite sections that do not apply to Drupal 7.

However, before we do that, I just noticed that the entire outer list in the Drupal 8 drupal_render() documentation is indented two spaces more than it should be:

 * The process of rendering an element is recursive unless the element defines
 * an implemented theme hook in #theme. During each call to drupal_render(), the
 * outermost renderable array (also known as an "element") is processed using
 * the following steps:
 *   - If this element has already been printed (#printed = TRUE) or the user
...

So can we have a patch that fixes that before we proceed to Drupal 7? Let's not change the wrapping, just indent that entire list (and sublists) back to the left by two spaces.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • jhodgdon committed 47ff642 on 8.3.x
    Issue #2015307 by thedavidmeister, meeli, Cottser: Overhaul docs for...

  • jhodgdon committed 47ff642 on 8.3.x
    Issue #2015307 by thedavidmeister, meeli, Cottser: Overhaul docs for...

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • jhodgdon committed 47ff642 on 8.4.x
    Issue #2015307 by thedavidmeister, meeli, Cottser: Overhaul docs for...

  • jhodgdon committed 47ff642 on 8.4.x
    Issue #2015307 by thedavidmeister, meeli, Cottser: Overhaul docs for...

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

andypost’s picture

Title: drupal_render() docs do not mention most of the base # attributes, adding default attributes to elements or how rendering works » \Drupal\Core\Render\RendererInterface::render() docs do not mention most of the base # attributes, adding default attributes to elements or how rendering works
Version: 8.9.x-dev » 9.3.x-dev

The drupal_render() is removed from 8.x core

andypost’s picture

star-szr’s picture

It's been 7 years, I think we should spin off that formatting fixup into a separate issue. And either close this or backport to 7.x.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Version: 9.4.x-dev » 8.0.x-dev
Status: Needs work » Fixed

Yes, a followup is a good option. It is now created #3270081: Fix indentation in doc block \Drupal\Core\Render\RendererInterface::render.

This was committed to 8.x so changing the status to Fixed and restoring the version.

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.