| 188 | |
| 189 | === Include template extension explicitly === |
| 190 | |
| 191 | Now, whenever referencing templates by name, you now pass the template's *full name* -- including its extension -- instead of the file's name without an extension. |
| 192 | |
| 193 | Given a template {{{polls/poll_detail.html}}}... |
| 194 | |
| 195 | Old: |
| 196 | {{{ |
| 197 | get_template('polls/poll_detail') |
| 198 | select_template(['polls/poll_detail', 'polls/poll_detail2']) |
| 199 | render_to_response('polls/poll_detail', {'poll': p}) |
| 200 | }}} |
| 201 | |
| 202 | New: |
| 203 | |
| 204 | {{{ |
| 205 | get_template('polls/poll_detail.html') |
| 206 | select_template(['polls/poll_detail.html', 'polls/poll_detail2.html']) |
| 207 | render_to_response('polls/poll_detail.html', {'poll': p}) |
| 208 | }}} |
| 209 | |
| 210 | This is changed in templates themselves, too -- notably in the {{{ {% extends %} }}} and {{{ {% include %} }}} template tags: |
| 211 | |
| 212 | Old: |
| 213 | {{{ |
| 214 | {% extends "base" %} |
| 215 | {% include "some_snippet" %} |
| 216 | }}} |
| 217 | |
| 218 | New: |
| 219 | {{{ |
| 220 | {% extends "base.html" %} |
| 221 | {% include "some_snippet.html" %} |
| 222 | }}} |
| 223 | |
| 224 | As a result of this change, the {{{TEMPLATE_FILE_EXTENSION}}} setting is gone, because there's no need for it. |
| 225 | |
| 226 | Clearly, this also means you can start putting whatever extension you want on templates. So if you'd like your templates to have a {{{.txt}}} extension, go for it. If you'd like to keep using {{{.html}}}, that's fine too. If you want to invent your own extension, or not even *use* an extension, be our guest. |
| 227 | |
| 228 | All the templates for the {{{django.contrib}}} apps -- most notably, the admin site -- still use {{{.html}}} extensions. |
| 229 | |
| 230 | Custom template tags created via {{{inclusion_tag()}}} should note the explicit template name (with the extension). For example, use {{{inclusion_tag('foo/bar.html')}}} instead of {{{inclusion_tag('foo/bar')}}}. |
| 231 | |
| 232 | Finally, note the syndication framework, which looks for templates with the name of the slug of each feed, now requires an '.html' extension on those templates. For example, if your feed has a slug {{{"hello"}}}, the syndication framework will look for the templates {{{feeds/hello_title.html}}} and {{{feeds/hello_description.html}}}. This is backwards-compatible. |