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:

Dougal said...

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?

Anonymous said...

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.

Anonymous said...

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

Fabio Zadrozny said...

Dougal:

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

Fabio Zadrozny said...

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

Fabio Zadrozny said...

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.

sw said...

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

Fabio Zadrozny said...

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

Sloan said...

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?

Fabio Zadrozny said...

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

Sloan said...

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

Sloan said...

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

Leo said...

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.

Fabio Zadrozny said...

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

Leo said...

Great, thanks Fabio!

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

Fabio Zadrozny said...

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

Thanos said...

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!

Fabio Zadrozny said...

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

Anonymous said...

Why is there no plugin version for Eclipse?

Fabio Zadrozny said...

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

Anonymous said...

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.

Fabio Zadrozny said...

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.

Unknown said...

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?

Saul said...

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?

Fabio Zadrozny said...

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

Fabio Zadrozny said...

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

Anonymous said...

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

Anonymous said...

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