Thursday, August 19, 2010

Django Templates Editor

Note: The new recommended way of having a Django Templates Editor is by using LiClipse: http://brainwy.github.io/liclipse/ (which is a commercial counterpart made to keep PyDev supported, as such it has PyDev standalone and a bunch of other goodies builtin).

Aptana Studio 3 still has PyDev and its own Django Templates Editor, but the bundled PyDev version is not kept up to date.

Below are more details on the integration on Aptana Studio 3 (using the Aptana Themes)






The highlighted tokens are the ones defined in the templates in the "Django tags" context (so, tags to be highlighted can be added or removed).





Also, there's code completion based on templates for the django-templates related stuff and pretty nice html completions inherited from the Aptana html editor.

The image below shows the html completions, a django-templates template completion and its result and a django-templates template completion for the filters.




That's it for now. Please grab it and let me know if it's working or if there's a bug lying around there so that it can be fixed before the official release :)

28 comments:

  1. How does it handle different versions of Django? For example the only one I can think of is the if statement changing and allowing more in recent versions. Does it pick that up?

    ReplyDelete
  2. Anonymous1:03 AM

    Idea of djngo templates editor is great!!!!

    But it should be available for Studio 2. Studio 3 is messy and unsuitable for production use. It lacks some important features, and lots of people don't want to use it.

    ReplyDelete
  3. Anonymous3:35 AM

    Thank you. It works.. But whats the point of having django templates editor when you're loosing css/js syntax highlighting in templates?

    ReplyDelete
  4. Dougal:

    Not currently, the templates are globally defined. Please enter a feature request to deal with that.

    ReplyDelete
  5. I know that Studio 3 is still in beta, but on the developers side it's already much improved in its multiple parsers and partitions handling (which is what made this editor possible to do and was one of the strong focus on Studio 3), so, unfortunately, this won't be backported to Studio 2 as it'd require too much effort.

    Although I know there's polishing needed in Studio 3, I think it's shaping up nicely and believe it'll be ready for production use in the upcoming months (if you require some given feature to work it does not provide, please report it to the studio dev team so that they can add it to their roadmap).

    ReplyDelete
  6. With this editor in place, the next step will be supporting other web-related languages that are also used with django-templates (so, css and js are already planned -- if you'd like it in other languages, please add a feature request for that). Until then, it's recommended using the default css and js editors for those.

    ReplyDelete
  7. What's up with the nbsp; in the template tags in the screenshots?

    ReplyDelete
  8. Not really sure, just copied the first example I looked for in the web ;-)

    ReplyDelete
  9. Sloan9:57 PM

    Greetings,

    Am I missing something - in my Preferences menu for Pydev I do not see the tab for Pydev\Django Templates Editor. I have Aptana 3.0 Build 3.0.0.201008191414 (this is the build date of August 19) and Pydev 1.6.1. Is there something else that I need to do to see the Django Template Editor under the Preferences?

    ReplyDelete
  10. Hi Sloan,

    It seems you're net in the nighly build (as the post says, the django templates is only available in the nightly for testing and still not in the final version).

    ReplyDelete
  11. Sloan1:08 PM

    Sorry for being slow - but how do I specifically download the nightly build. The only url I see to download Aptana 3.0 is http://aptana.com/products/studio3/download - how do I download the nightly build of the 3.0 beta?

    Thanks

    ReplyDelete
  12. Sloan1:58 PM

    I answered my own question - I needed to download the Pydev nightly build and not the Aptana nightly build. Works for me now :)

    ReplyDelete
  13. Updating Aptana to the latest build now installs PyDev 0.9.7.1 - which requires me to remove 1.6.1. What's happening here? is it a version renumbering? or what's going on here?

    Once 0.9.7.1 is installed, I can't remove just it to install 1.6.1 - its a part of the Aptana core.

    ReplyDelete
  14. The build went out with the wrong number. I'll make sure that the next build is fixed (should be out this week or the next one).

    ReplyDelete
  15. Great, thanks Fabio!

    Will this feature be available in the regular Eclipse version as well? or just exclusive to Aptana?

    ReplyDelete
  16. Hi Leo,

    This version is dependent on the Aptana HTML editor, so, to use it in a regular Eclipse install, the required Aptana plugins must also be installed.

    Note that Pydev is now shipping with Aptana Studio 3, and the next release will have Pydev with the django templates editor installed by default, which should help those that struggle with the eclipse update manager (the first release ended up getting out with the wrong pydev version, but this is already fixed and a new release should be available in this week or the next).

    ReplyDelete
  17. Thanos11:39 AM

    Used the latest Aptana Studio 3 Beta with the django template highlighting included and noticed that the "else" tag was missing from the tags list.

    It's nice that I could add it myself. Other that, it looks very nice. Thanks!

    ReplyDelete
  18. Just fixed the missing "else" (thanks for the report).

    ReplyDelete
  19. Anonymous4:43 AM

    Why is there no plugin version for Eclipse?

    ReplyDelete
  20. The major problem is trying to reinvent the wheel here. Doing a proper html editor with css and javascript support is far from trivial, so, it makes sense using an editor which already provides that, which in this case is the Aptana html editor, with the plus that it'll improve as this editor also improves (and note that Aptana is actually a set of plugins on top of Eclipse).

    ReplyDelete
  21. Anonymous9:24 AM

    really bad choice to change the default eclipse theme. Hated it.

    Finally after struggling to find out where the thing was, I'd my env mostly as I wanted, but some views still look weird,

    The django template editor just don't pay off the anoying things, so I just uninstalled aptana and went back to plain pydev.

    ReplyDelete
  22. Hi anonymous,

    It'd be nice if you could post what didn't get as you wanted so that this can be fixed.

    The editor preferences when in Aptana was improved in the latest release (1.6.3), so, it should be easier to find stuff and configure colors as you want.

    ReplyDelete
  23. Is it documented anywhere how to configure the template editor? I have Aptana 3 and everything looks like it does in your screenshots, except Aptana is showing errors for my templates indicating that it is treating them like html, not django templates. How does the editor know which html files are django templates?

    ReplyDelete
  24. When trying to install Aptana 3 plugins for Eclipse, after installing Pydev nightly, i get this error.
    http://www.text-upload.com/read.php?id=127608&c=1065266 Do i need to uninstall Pydev fist? Will that mess with any of the Pydev Django projects I have made?

    ReplyDelete
  25. Yes, Aptana Studio 3 already contains PyDev (i.e.: it's a superset), so, if you want Aptana Studio 3, you have to remove PyDev.

    There are notes related to that at: http://pydev.org/download.html

    ReplyDelete
  26. @Unknown: please create a bug-report with the errors you're having.

    ReplyDelete
  27. Anonymous12:40 PM

    Hi everybody

    Is it possible to change background color for tags in DJango templates?

    In every Aptana theme tag are colored the same and there is no option to change it.

    Regards
    Bronek

    ReplyDelete
  28. Anonymous3:38 PM

    Hi

    I've fixed out the problem about background color. Previous color leaves until eclipse restarts.

    Another problem is when I use Scope Selectors:
    source.dj
    source.django_templates.embedded.tag.html
    there are no changes in syntax colors.

    Regards
    Bronek

    ReplyDelete