summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@oscaro.com>2015-03-05 09:13:56 -0500
committerTim Graham <timograham@gmail.com>2015-03-05 10:00:17 -0500
commit7d3418c9cd00acc32e01aa42c2bf226bf795b39c (patch)
tree2b78a6f05c91359d6956e8c9db57cd9216b7d98c
parentc5a8b442bdbb70cd34595f6c8c6d10bb6d038989 (diff)
[1.6.x] Improved get_media_prefix template tag example.
Backport of 9a4a9a8a49ed3e38f3038b8d6fc7c405256271f1 from master
-rw-r--r--docs/ref/templates/builtins.txt8
1 files changed, 5 insertions, 3 deletions
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
index a0fcf11800..c7a6711ee9 100644
--- a/docs/ref/templates/builtins.txt
+++ b/docs/ref/templates/builtins.txt
@@ -2533,6 +2533,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.