From 9432f1e750eca440e19903ee1b1cef0679f6f98b Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Mon, 18 Aug 2014 20:37:16 -0400 Subject: [PATCH] Fixed some doc errors that caused syntax highlighting to fail. --- docs/ref/forms/widgets.txt | 4 ++-- docs/ref/templates/api.txt | 2 +- docs/ref/templates/builtins.txt | 2 +- docs/topics/i18n/translation.txt | 4 +++- docs/topics/security.txt | 2 +- docs/topics/templates.txt | 27 ++++++++++++++++----------- 6 files changed, 24 insertions(+), 17 deletions(-) diff --git a/docs/ref/forms/widgets.txt b/docs/ref/forms/widgets.txt index 541f43dcb3..fe5920eee3 100644 --- a/docs/ref/forms/widgets.txt +++ b/docs/ref/forms/widgets.txt @@ -569,7 +569,7 @@ Selector and checkbox widgets .. code-block:: html @@ -663,7 +663,7 @@ Selector and checkbox widgets .. code-block:: html diff --git a/docs/ref/templates/api.txt b/docs/ref/templates/api.txt index a058ee032b..0a50e5e243 100644 --- a/docs/ref/templates/api.txt +++ b/docs/ref/templates/api.txt @@ -320,7 +320,7 @@ If you ``pop()`` too much, it'll raise >>> c.pop() Traceback (most recent call last): ... - django.template.ContextPopException + ContextPopException .. versionadded:: 1.7 diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt index 516ddbe1de..da860c4bb7 100644 --- a/docs/ref/templates/builtins.txt +++ b/docs/ref/templates/builtins.txt @@ -108,7 +108,7 @@ Variables included in the cycle will be escaped. You can disable auto-escaping with:: {% for o in some_list %} - ... {% endfor %} diff --git a/docs/topics/i18n/translation.txt b/docs/topics/i18n/translation.txt index a60a0a2161..19ddef9244 100644 --- a/docs/topics/i18n/translation.txt +++ b/docs/topics/i18n/translation.txt @@ -1329,7 +1329,9 @@ For example, if your Django app contained a translation string for the text _("Welcome to my site.") ...then :djadmin:`django-admin makemessages ` will have created -a ``.po`` file containing the following snippet -- a message:: +a ``.po`` file containing the following snippet -- a message: + +.. code-block:: po #: path/to/python/module.py:23 msgid "Welcome to my site." diff --git a/docs/topics/security.txt b/docs/topics/security.txt index 3fe20a3cc3..a3e656557b 100644 --- a/docs/topics/security.txt +++ b/docs/topics/security.txt @@ -31,7 +31,7 @@ protect the following: .. code-block:: html+django - + If ``var`` is set to ``'class1 onmouseover=javascript:func()'``, this can result in unauthorized JavaScript execution, depending on how the browser renders diff --git a/docs/topics/templates.txt b/docs/topics/templates.txt index e50e7c96f7..40e1e9e2c7 100644 --- a/docs/topics/templates.txt +++ b/docs/topics/templates.txt @@ -549,9 +549,10 @@ disabled. Here is an example template:: The auto-escaping tag passes its effect onto templates that extend the current one as well as templates included via the :ttag:`include` tag, -just like all block tags. For example:: +just like all block tags. For example: - # base.html +.. snippet:: + :filename: base.html {% autoescape off %}

{% block title %}{% endblock %}

@@ -559,18 +560,18 @@ just like all block tags. For example:: {% endblock %} {% endautoescape %} - - # child.html +.. snippet:: + :filename: child.html {% extends "base.html" %} - {% block title %}This & that{% endblock %} + {% block title %}This & that{% endblock %} {% block content %}{{ greeting }}{% endblock %} Because auto-escaping is turned off in the base template, it will also be turned off in the child template, resulting in the following rendered HTML when the ``greeting`` variable contains the string ``Hello!``:: -

This & that

+

This & that

Hello! Notes @@ -606,9 +607,9 @@ This means you would write :: {{ data|default:"3 < 2" }} -...rather than :: +...rather than:: - {{ data|default:"3 < 2" }} <-- Bad! Don't do this. + {{ data|default:"3 < 2" }} {# Bad! Don't do this. #} This doesn't affect what happens to data coming from the variable itself. The variable's contents are still automatically escaped, if necessary, because @@ -638,14 +639,18 @@ of all comments related to the current task with:: {{ task.comment_set.all.count }} And of course you can easily access methods you've explicitly defined on your -own models:: +own models: + +.. snippet:: + :filename: models.py - # In model class Task(models.Model): def foo(self): return "bar" - # In template +.. snippet:: + :filename: template.html + {{ task.foo }} Because Django intentionally limits the amount of logic processing available