Hello Emil, 2015-05-30 17:52 GMT+01:00 Emil Stenström <[email protected]>:
> But what needs to happen is that the same templates that Django uses needs > to be accessible to, and executable in, javascript. > > For this to work, two things needs to be built: > > 1. A way to access the template and the template context for a view > separately, so that it can be delivered to the client. Maybe the easiest > would be to modify django.shortcuts.render so it returns both the input and > the result. The client could then get access to this via a <script> tag > when the page renders. > I'm not sure I understand why changes to render() are necessary. If you intend to use the system you've described in your own views, you can use your own variant of render that returns an appropriate HttpResponse subclass. It's unclear to me that you can reasonably plug such a system on views provided by third-party apps, since context data generated by these views will often not be JSON-serializable. Could you clarify the reasons for this feature request? > 2. A template language that has a solid javascript implementation. To be > able to render the templates the server side and client side must use the > same language. I see two options here, either make sure the Jinja flavor we > are supporting works with JS templatations (maybe > https://mozilla.github.io/nunjucks/ ?), or get a handlebars > implementation working with Django (https://github.com/wbond/pybars3 ?). > Or maybe there's some third option I didn't think of... > To achieve this goal, I think Andrew Ingram's second suggestion is the easiest solution since Django 1.8: implement a template engine that hands over data to a Node.js process, lets it render the template, gets the HTML back, and returns it. That's a good candidate for a pluggable application. It will probably have some specific deployment instructions ("run this Node.js next to your Django...) -- Aymeric. -- 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 [email protected]. To post to this group, send email to [email protected]. 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/CANE-7mX5TTsFm0TSRu982dhho-BBZQHbL_GBggbVQ_UdwoYhtQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
