﻿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
10219	Template tag for declaring constants	Daniel Pope <dan@…>	nobody	"I often need to reproduce the title several times in each template I write. For example most of my templates end up starting like this:

{{{
{% extends ""base.html"" %}
{% block title %}{{t}}{% endblock %}
{% block pagetitle %}{{t}}{% endblock %}
{% block breadcrumbs %}<li>{{t}}</li>{% endblock %}
}}}

This anti-pattern emerges from the lack of ability to pass any information up the template inheritance chain. I run into the same thing when a base template includes menus or tabs; to show which tab or menu item is selected requires that I copy-and-paste the menu code into each template, only to change which item is displayed as selected.

I think this is a bad thing for maintainability as even slight changes in base templates mean all sub-templates have to be amended. If the inherited template could pass constants to its super-template, the title could be re-used in several places and the menu could be written in one place using {{{{% ifequal %}}}}. For example, an appropriate syntax might look like this:

{{{
{% extends ""base.html"" %}
{% define TITLE t %}
{% define TAB ""home"" %}
}}}

All templates in the hierarchy would execute with {{{{'TITLE': t, 'TAB': 'home'}}}} added to the context. With multiple levels of inheritance, a template's defines would override those in its hierarchy. ('define' is used for declaring constants in C and PHP; uppercase is a widely-used convention for constants)."		closed	Template system	1.0		wontfix	constant, tag		Unreviewed	0	0	0	0	0	0
