Opened 5 years ago

Closed 5 years ago

#24021 closed Uncategorized (wontfix)

Template Variables Being Passed Through 'Using'

Reported by: clu24 Owned by: nobody
Component: Template system Version: master
Severity: Normal Keywords: Template, Using
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


An idea to make templates a little easier for users.

Let's say you have a larger template that houses smaller template "fragments." These smaller templates have ten variables + that need to be defined in order for these templates to work.

Instead of adding with for each variable, how about adding 'using' where you define a dictionary that holds all the variables. That was way, for each template you are able to just include a dictionary for templates inside of templates and so on.

Before: {% include 'example.html' with hello=something.hello bye=something.bye...etc. %}

After: {% include 'example.html' using something %}

Change History (1)

comment:1 Changed 5 years ago by Russell Keith-Magee

Resolution: wontfix
Status: newclosed

Thanks for the suggestion - but I'm going to say No to this one. I afraid I don't see the benefit in introducing a new syntax element purely to avoid a level of namespace. If you don't want to pass in lots of variables, but you're willing to pass in a dictionary, why not just use the dictionary as an argument?

{% include 'example.html' with something=something %}

If you want to argue your case, please open a discussion on django-developers.

Note: See TracTickets for help on using tickets.
Back to Top