mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #18254 -- Added ability to the static template tags to store the result in a contextt variable. Many thanks to Andrei Antoukh for the initial patch.
This commit is contained in:
parent
8dafd04c45
commit
0a68a2994b
6 changed files with 118 additions and 11 deletions
|
@ -387,6 +387,17 @@ The previous example is equal to calling the ``url`` method of an instance of
|
|||
useful when using a non-local storage backend to deploy files as documented
|
||||
in :ref:`staticfiles-from-cdn`.
|
||||
|
||||
.. versionadded:: 1.5
|
||||
|
||||
If you'd like to retrieve a static URL without displaying it, you can use a
|
||||
slightly different call::
|
||||
|
||||
.. code-block:: html+django
|
||||
|
||||
{% load static from staticfiles %}
|
||||
{% static "images/hi.jpg" as myphoto %}
|
||||
<img src="{{ myphoto }}" alt="Hi!" />
|
||||
|
||||
Other Helpers
|
||||
=============
|
||||
|
||||
|
|
|
@ -2354,6 +2354,17 @@ It is also able to consume standard context variables, e.g. assuming a
|
|||
{% load static %}
|
||||
<link rel="stylesheet" href="{% static user_stylesheet %}" type="text/css" media="screen" />
|
||||
|
||||
If you'd like to retrieve a static URL without displaying it, you can use a
|
||||
slightly different call::
|
||||
|
||||
.. versionadded:: 1.5
|
||||
|
||||
.. code-block:: html+django
|
||||
|
||||
{% load static %}
|
||||
{% static "images/hi.jpg" as myphoto %}
|
||||
<img src="{{ myphoto }}"></img>
|
||||
|
||||
.. note::
|
||||
|
||||
The :mod:`staticfiles<django.contrib.staticfiles>` contrib app also ships
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue