Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291302

Auto escaping url of external library

$
0
0

Hello! Today I try to define external library in mymodule.libraries.yml (url of external lib: https://www.google.com/recaptcha/api.js?onload=callback&render=explicit&hl=en). But in result on page all ampersands were replaced on thier html code (&):

<script src="https://www.google.com/recaptcha/api.js?onload=callback&amp;render=explicit&amp;hl=ru"></script>

On the documentation page there is an example (Adding stylesheets (CSS) and JavaScript (JS) to a Drupal 8 theme) :

For example:

https://maps.googleapis.com/maps/api/js?key=myownapikey&signed_in=true&libraries=drawing&callback=initMap:
  type: external
  attributes:
    defer: true
    async: true
    data-test: map-link

This would result in the following markup:

<script src="https://maps.googleapis.com/maps/api/js?key=myownapikey&signed_in=true&libraries=drawing&callback=initMap" async defer data-test="map-link"></script>

It's don't work. After render all ampersands were replaced on their html code.

It's make __toString mthod of AttributeString class:

class AttributeString extends AttributeValueBase {

  /**
   * Implements the magic __toString() method.
   */
  public function __toString() {
    return Html::escape($this->value);
  }

}

How do I include external library with get parameters ?


Viewing all articles
Browse latest Browse all 291302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>