Skip to content
Myr

docs: `script` -> ``script``

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by defuz · committed by defuz · parent d338dc8 · Browse files · 3 files+6 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+6 added−6 removed

  • other:+6 added−6 removed

3 files+6 added−6 removed

modified:docs/patterns/jquery.rst+2 added-2 removed
63 unmodified lines
64 </script>6566The ``|safe`` is necessary in Flask before 0.10 so that Jinja does not67escape the JSON encoded string with HTML rules. Usually this would be68necessary, but we are inside a `script` block here where different rules68necessary, but we are inside a ``script`` block here where different rules69apply.7071.. admonition:: Information for Pros7273 In HTML the `script` tag is declared `CDATA` which means that entities73 In HTML the ``script`` tag is declared ``CDATA`` which means that entities74 will not be parsed. Everything until ``</script>`` is handled as script.75 This also means that there must never be any ``</`` between the script76 tags. ``|tojson`` is kind enough to do the right thing here and77 escape slashes for you (``{{ "</script>"|tojson|safe }}`` is rendered as
91 unmodified lines
modified:docs/api.rst+2 added-2 removed
374 unmodified lines
375 will have that method called and then the return value is serialized376 as string.377378The :func:`~htmlsafe_dumps` function of this json module is also available379as filter called ``|tojson`` in Jinja2. Note that inside `script`379as filter called ``|tojson`` in Jinja2. Note that inside ``script``380tags no escaping must take place, so make sure to disable escaping381with ``|safe`` if you intend to use it inside `script` tags unless381with ``|safe`` if you intend to use it inside ``script`` tags unless382you are using Flask 0.10 which implies that:383384.. sourcecode:: html+jinja385
404 unmodified lines
modified:docs/templating.rst+2 added-2 removed
103 unmodified lines
104 This function converts the given object into JSON representation. This105 is for example very helpful if you try to generate JavaScript on the106 fly.107108 Note that inside `script` tags no escaping must take place, so make108 Note that inside ``script`` tags no escaping must take place, so make109 sure to disable escaping with ``|safe`` before Flask 0.10 if you intend110 to use it inside `script` tags:110 to use it inside ``script`` tags:111112 .. sourcecode:: html+jinja113114 <script type=text/javascript>
108 unmodified lines