﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
15053	Make templates more reusable by Improving template loading algorithm to avoid extending infinite recursion	Pablo Martín	Unai Zalakain	"Many times when we use a django application we need to adapt it a little bit. Often this adaptation is just a little change in the html.

So we have to copy the application template into our project templates.

It would be awesome that the template loading algorithm let us to overwrite just the template blocks we want to change.

For example: If we use [http://code.google.com/p/django-profile/ django profile] and we want to modify the title of the [http://code.google.com/p/django-profile/source/browse/trunk/userprofile/templates/userprofile/account/login.html?r=457 login] template from ""User login"" to ""Login"" we have to copy and paste 51 lines of code. If we want to add a new javascript resource we have to copy and paste 51 lines of code and so on.

But if we could adapt the template loading system so it could use the order of the loaders to avoid extending cycles, we could do the above example with a template (in our project directory) like this:

Template: userprofile/account/login.html

{{{

{% extends ""userprofile/account/login.html""%} {% comment %} this doesn't extend itself but the application template {% endcomment %}

{% load i18n%}

{% block title%} {% trans ""Login""%} {% endblock%}

}}}

{{{

TEMPLATE_LOADERS = (
  'django.template.loaders.filesystem.Loader',
  'django.template.loaders.app_directories.Loader',
  #     'django.template.loaders.eggs.Loader',
)
}}}


We have an [http://code.google.com/p/django-smart-extends/ implementation] that works on Django 1.2 and Django 1.1. But if we set TEMPLATE_DEBUG = True in settings.py we need to patch Django:
 * Django 1.2 (trunk r15173) attachment
 * [http://code.google.com/p/django-smart-extends/source/browse/trunk/patches/patch1.2.diff Django 1.2]
 * [http://code.google.com/p/django-smart-extends/source/browse/branches/django_1.1.X/patches/patch1.1.X.diff Django 1.1]

This also works with others template loaders."	New feature	closed	Template system	dev	Normal	fixed		Andy Baker kmike84@… Florian Apolloner mmitar@… riccardo.magliocchetti@… julenx@…	Ready for checkin	1	0	0	0	0	0
