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 :)

Template Components
-------------------

React.js popularized the notion that in front-end development, code organization
should be based on interface components, not split up into HTML, Javascript and
CSS. Here's the original presentation and the rationale behind organizing around
components:
https://www.youtube.com/watch?v=x7cQ3mrcKaY&t=2m7s

This is a nice react.js introduction:
https://facebook.github.io/react/docs/thinking-in-react.html

[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 :)

thanks

--
Riccardo Magliocchetti
@rmistaken

http://menodizero.it

--
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/556AC614.5010604%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to