diff options
| author | Aymeric Augustin <aymeric.augustin@oscaro.com> | 2015-03-05 09:13:56 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-03-05 10:00:05 -0500 |
| commit | 2bef57f3fb523d67ddf2d0d2db0180a21c9fd989 (patch) | |
| tree | 7815e26860ec0469532e8cf22b1ab0dba2b12427 | |
| parent | 3bc35f7e08cd1752722a37c70c295d373e7214a8 (diff) | |
[1.8.x] Improved get_media_prefix template tag example.
Backport of 9a4a9a8a49ed3e38f3038b8d6fc7c405256271f1 from master
| -rw-r--r-- | docs/ref/templates/builtins.txt | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt index b9d2afb603..bc2e7d546e 100644 --- a/docs/ref/templates/builtins.txt +++ b/docs/ref/templates/builtins.txt @@ -2620,6 +2620,8 @@ get_media_prefix Similar to the :ttag:`get_static_prefix`, ``get_media_prefix`` populates a template variable with the media prefix :setting:`MEDIA_URL`, e.g.:: - <script type="text/javascript" charset="utf-8"> - var media_path = '{% get_media_prefix %}'; - </script> + {% load static %} + <body data-media-url="{% get_media_prefix %}"> + +By storing the value in a data attribute, we ensure it's escaped appropriately +if we want to use it in a JavaScript context. |
