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&render=explicit&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 ?