Search code examples
djangoeclipsetemplateseclipse-plugineclipse-templates

Writing eclipse templates


I am writing django templates in Eclipse->prefrences->templates, to autocomplete DJango templates. I wrote this

{% block ${cursor} %}

{% endblock %}

Now, when I request and do autocompletion, after typing {% the autocompletion is

{% {% block  %}

{% endblock %}

While I would like

{% block  %}

{% endblock %}

With cursor after block. How can I do this?


Solution

  • Instead of typing {% and selecting dj_for_empty, try typing dj_ and then auto-completing. It will behave the way you expect in that case.

    BOTTOM-LINE: You auto-complete the templates into the editor based on the template name, not based on the template contents.

    It appears that autocompletion has two sources: regular HTML tags (for which I can't find the definitions to change anywhere in Eclipse, sorry) and the templates themselves (which you correctly demonstrated in your comment with the screenshot).

    Look at this image:

    alt text

    Instead of typing <t and triggering auto-complete, I typed t. You can see that there are entries with <> - indicating these are autocompletions based on the actual HTML tag - and entries with # - indicating these are autocompletions based on a template.

    It appears templates are to be accessed by the name of the template. Notice that the template named table provides a complete <table> and not just the <table></table> that is autocompleted if you just type <tab and autocompletes.