Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Javascript/CSS Syntax highlighting within custom tag(Is it possible to have Javascript/CSS syntax highlighting within a custom tag)
Javascript/CSS Syntax highlighting within custom tag [message #529372] Sat, 24 April 2010 09:10 Go to next message
Mookle  is currently offline Mookle
Messages: 3
Registered: April 2010
Junior Member
I'm in the process of building a custom tag library that will allow me to include css and/or javascript in any part of a jsp page.

The custom tag will then ensure that all javascript/css spread throughout the page is collated and added to the <head> of the document.
The issue I'm finding is that I can't find a method to inform the jsp editor that the content of my custom tag is javascript or css.

Is there a way that I can force the jsp editor to recognise that content held in a custom tag is javascript or css?

So for example the code could look something like:
<ctag:javascript>
function myFunc(){
document.getElementById("example").style.display="block";
}
</ctag>
<ctag:style>
#example { width:100px; }
</ctag:style>
<div id="example">This is an example</div>

I'm happy to do ground work in enhancing the WTP JSP editor if needs be, just not sure where to start.

Thanks in advance for any help you can offer.
Re: Javascript/CSS Syntax highlighting within custom tag [message #529701 is a reply to message #529372] Mon, 26 April 2010 19:49 Go to previous messageGo to next message
Nick Sandonato is currently offline Nick Sandonato
Messages: 126
Registered: July 2009
Senior Member
There is currently no way for you to identify the text content of your custom tags as either javascript or CSS.

The way the text in between <style> or <script> tags works is that it becomes a new partition, which the line style providers (syntax highlighting) and content assistants operate off of. So you would more or less need to mimic how the partitioners identify <script> and <style> blocks as their respective partitions.

Check out org.eclipse.jst.jsp.core.internal.text.StructuredTextPartiti onerForJSP, which embeds the StructuredTextPartitionerForHTML. The HTML partitioner is the one responsible for identifying <script> and <style> blocks.
Re: Javascript/CSS Syntax highlighting within custom tag [message #529896 is a reply to message #529372] Tue, 27 April 2010 15:29 Go to previous messageGo to next message
Mookle  is currently offline Mookle
Messages: 3
Registered: April 2010
Junior Member
Thanks for your help Nick. That certainly is a good starting point.
Much Appreciated

Mookle
Re: Javascript/CSS Syntax highlighting within custom tag [message #532355 is a reply to message #529701] Sat, 08 May 2010 18:56 Go to previous messageGo to next message
Roberto  is currently offline Roberto
Messages: 1
Registered: May 2010
Junior Member
Hi Nick,

I found this post digging into google, trying to find the way to customize syntax highlighting on eclipse.

I think that this discussion treats just the thing that I'm looking for.

I'm trying to define a 'special rule' for allowing javascript highlighting into html files. The question is that I'm using Zend Framework and it is a common practice to embed javascript into the html using these two functions:

<? $this->headScript()->captureStart() ?>

// Javascript code goes here

<? $this->headScript()->captureEnd() ?>

I'm trying to find the file that eclipse uses for load languages definitions and modify it to enable this behaviour.

Is it possible? Is there a file that I can edit for customize syntax highligthing?

Thank you very much for your help!!!

Roberto
Re: Javascript/CSS Syntax highlighting within custom tag [message #532972 is a reply to message #532355] Tue, 11 May 2010 17:59 Go to previous message
Nick Sandonato is currently offline Nick Sandonato
Messages: 126
Registered: July 2009
Senior Member
Hi Roberto,

I can't speak for the PDT, but in WTP we don't have any configuration files that you can edit to customize syntax highlighting rules.

You'd pretty much have to do as mentioned earlier.

If this is a common convention, it might be something you could request from the PDT to support.
Previous Topic:Eclipe Helios server adapters
Next Topic:Incorrect formatting of Javascript line comments
Goto Forum:
  


Current Time: Thu Oct 02 16:33:54 GMT 2014

Powered by FUDForum. Page generated in 0.01923 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software