Hi, On Sunday, 31 May 2015 10:27:24 UTC+2, riccardo.magliocchetti wrote: > > Hi, > > Il 30/05/2015 18:52, Emil Stenström ha scritto: > > Hi, > > > > This is the first feature proposal as part of my general drive for > getting > > Django to work better for javascript heavy sites. > > This is a bold premise :) >
Yes, I know it is bold. If you look at my three proposed features together, and think of a Django with these features included... I would definitely think that building javascript applications would be much easier. That's how I think of this. [snip] > > ... which define a kind of component, but one that is tied to a form > field. My > > suggestion is a new package: django.template.component, that builds on > the Media > > class from Form Assets, and allows you to define your components like > this: > > > > from django.template import component > > class Calendar(component.Component): > > def context(self, date): > > return {"date": date} > > class Media: > > template = "app/components/calendar/calendar.html" > > css = {'all': ('app/components/calendar/calendar.css',)} > > js = ('app/components/calendar/calendar.js',) > > > > component.register(name="calendar", component=Calendar) > > > > ... and later in your template: > > > > {% load components %} > > {% block extra_media %}{% component_dependencies %}{% endblock %} > > {% block main %} > > {% component "calendar" date=custom_date %} > > {% endblock %} > > But your proposal keeps html and js separated. I think you are solving a > problem > for the one that just want to use a component but you are not solving the > problem for the one that is writing components. At least not in the > react.js > way, especially from such a bold premise :) > I agree that I don't quite do it the same way as React. But that's not the point here either, to somehow bundle Reacts ideas inside Django. My point is that keeping the four parts that make a component closely together in the project source, would make for a better structure. They only idea that comes from React is thinking in components rather than nested templates and template tags, which are Django's current way of solving this. So this is really a rather small suggestion, but that I think would make the component mindset fit better in with Django. Also, a lot of the code is already written in the Media class. Thanks for taking the time to comment! /E -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/9540de56-ba65-4309-96d7-be5eb216aea0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.