Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure Eclipse to use Javascript editor

When editing JSPs in Eclipse, the contents of <script> tags - i.e. Javascript code - is properly color coded and formated.

For reasons that go beyond the scope of this question, I have created a custom javascript tag, let's call it <sj:script>. The body of this type is pure javascript as you would have in a regular <script> tag.

However, when I have Javascript code within my custom tag, it is treated as simple text (no color coding, no proper indentation, etc).

My question is, how do I make Eclipse use a specific editor within custom JSP tags?

like image 765
jd. Avatar asked Nov 24 '10 04:11

jd.


1 Answers

You can try MyEclipse or Aptana Studio. They offer much better editors for web development.

But a much better approach is to put the JS into a different file and reference that with <script src="...">:

  1. You can use a better editor
  2. The browser can cache the JavaScript (instead of downloading it every time with the rest of the page)
  3. You can write tests for the JavaScript (next to impossible when the JS is held hostage in a JSP file).

[EDIT] Eclipse is open source. Download the code for the WTP project, look for the text editor parts and search for "script". In all places that you find, add "sj:script", too.

like image 76
Aaron Digulla Avatar answered Sep 20 '22 21:09

Aaron Digulla