mirror of
https://github.com/django/django.git
synced 2024-11-21 19:09:18 +01:00
Extend documentation
This commit is contained in:
parent
19b35b2a22
commit
d847e3376e
@ -72,11 +72,13 @@ class MediaAsset:
|
|||||||
self.attributes = attributes
|
self.attributes = attributes
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
|
# Compare the path only, to ensure performant comparison in Media.merge.
|
||||||
return (self.__class__ is other.__class__ and self.path == other.path) or (
|
return (self.__class__ is other.__class__ and self.path == other.path) or (
|
||||||
isinstance(other, str) and self._path == other
|
isinstance(other, str) and self._path == other
|
||||||
)
|
)
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
|
# Hash the path only, to ensure performant comparison in Media.merge.
|
||||||
return hash(self._path)
|
return hash(self._path)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -283,14 +283,27 @@ you to pass custom HTML attributes::
|
|||||||
css = {
|
css = {
|
||||||
"all": [CSS("pretty.css", media="all", crossorigin="anonymous")],
|
"all": [CSS("pretty.css", media="all", crossorigin="anonymous")],
|
||||||
}
|
}
|
||||||
js = [JS("animations.js", defer=True)]
|
js = [
|
||||||
|
JS(
|
||||||
|
"https://code.jquery.com/jquery-3.3.1.slim.min.js",
|
||||||
|
**{
|
||||||
|
"integrity"="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
|
||||||
|
"crossorigin"="anonymous",
|
||||||
|
"async": True,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
If this Media definition were to be rendered, it would become the following HTML:
|
If this Media definition were to be rendered, it would become the following HTML:
|
||||||
|
|
||||||
.. code-block:: html+django
|
.. code-block:: html+django
|
||||||
|
|
||||||
<script src="https://static.example.com/animations.js" defer></script>
|
|
||||||
<link href="https://static.example.com/pretty.css" media="all" crossorigin="anonymous" rel="stylesheet">
|
<link href="https://static.example.com/pretty.css" media="all" crossorigin="anonymous" rel="stylesheet">
|
||||||
|
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
|
||||||
|
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
|
||||||
|
crossorigin="anonymous"
|
||||||
|
async>
|
||||||
|
</script>
|
||||||
|
|
||||||
..note:: The ``media`` attribute on the CSS-object overrides the dictionary key.
|
..note:: The ``media`` attribute on the CSS-object overrides the dictionary key.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user