You are here

public static function AmpCustomStyle::preRenderConditionalComments in Accelerated Mobile Pages (AMP) 8.3

Pre-render callback: Renders #browsers into #prefix and #suffix.

Parameters

array $element: A render array with a '#browsers' property. The '#browsers' property can contain any or all of the following keys:

  • 'IE': If FALSE, the element is not rendered by Internet Explorer. If TRUE, the element is rendered by Internet Explorer. Can also be a string containing an expression for Internet Explorer to evaluate as part of a conditional comment. For example, this can be set to 'lt IE 7' for the element to be rendered in Internet Explorer 6, but not in Internet Explorer 7 or higher. Defaults to TRUE.
  • '!IE': If FALSE, the element is not rendered by browsers other than Internet Explorer. If TRUE, the element is rendered by those browsers. Defaults to TRUE.

Examples:

  • To render an element in all browsers, '#browsers' can be left out or set to array('IE' => TRUE, '!IE' => TRUE).
  • To render an element in Internet Explorer only, '#browsers' can be set to array('!IE' => FALSE).
  • To render an element in Internet Explorer 6 only, '#browsers' can be set to array('IE' => 'lt IE 7', '!IE' => FALSE).
  • To render an element in Internet Explorer 8 and higher and in all other browsers, '#browsers' can be set to array('IE' => 'gte IE 8').

Return value

array The passed-in element with markup for conditional comments potentially added to '#prefix' and '#suffix'.

Overrides HtmlTag::preRenderConditionalComments

File

src/Element/AmpCustomStyle.php, line 57

Class

AmpCustomStyle
Provides a render element for the amp-custom style tag.

Namespace

Drupal\amp\Element

Code

public static function preRenderConditionalComments($element) {

  // Browser-specific comments won't apply or work in AMP inline styles.
  return $element;
}