Re: DRY in templates
Unless I didn't read closely enough, this sounds to me like you could use inclusion tags: http://www.djangoproject.com/documentation/templates_python/#inclusion-tags --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: DRY in templates
1. refactor the blocks you want into separate templates , do something like {%include 'block1.html'%} , {%include 'block2.html'%}. I guess this is what you want. or 2. "You can use as many levels of inheritance as needed." Luis P. Mendes wrote: > Hi, > > I have several applications running and each of them has its own > template files. They're working fine. > > Then, I decided that I should create another application that would > merge all data information from each of those separated ones mentioned > above. > > There were two problems to consider: > 1- regarding data and views > 2- regarding templates > > As for 1, I found a way that follows the DRY principle. For each > function that would be requested I joined another field as an argument. > From: ex: def viewListA(request): > To:def viewListA(request, integrated = False): > Integrated is True when the request is demanded by the global application. > If Integrated == False, the function returns the html file corresponding > to it; if True, it returns 'request'. > > So far, so good. > > Now, for part nr. 2. > > I didn't find a way not to repeat the same lines of the partial html > files in a big global html one, for the application that merges all > information. My concern is only about data information that is > presented mostly in tables. > > I am aware of the {% extends ... %} tag, but it can only be used once > per file. Otherwise, I could use that tag for each of the partial > templates and would import the data blocks of each of them. > > My question is this one: Is there a way I don't have to repeat the same > template coding for the above illustrated example? > > Luis P. Mendes --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
DRY in templates
Hi, I have several applications running and each of them has its own template files. They're working fine. Then, I decided that I should create another application that would merge all data information from each of those separated ones mentioned above. There were two problems to consider: 1- regarding data and views 2- regarding templates As for 1, I found a way that follows the DRY principle. For each function that would be requested I joined another field as an argument. From: ex: def viewListA(request): To:def viewListA(request, integrated = False): Integrated is True when the request is demanded by the global application. If Integrated == False, the function returns the html file corresponding to it; if True, it returns 'request'. So far, so good. Now, for part nr. 2. I didn't find a way not to repeat the same lines of the partial html files in a big global html one, for the application that merges all information. My concern is only about data information that is presented mostly in tables. I am aware of the {% extends ... %} tag, but it can only be used once per file. Otherwise, I could use that tag for each of the partial templates and would import the data blocks of each of them. My question is this one: Is there a way I don't have to repeat the same template coding for the above illustrated example? Luis P. Mendes --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---