Make IntelliJ 11 treat aui:script the same as script

Hey All,

I feel like this should be so simple, but it's eluding me!

I'm trying to make:

<aui:script use="xxx,yyy,zzz">
   function a() {
      alert('test');
   }
</aui:script>

highlight and self indent EXACTLY like:


<script>
   function a() {
      alert('test');
   }
</script>



I tried duplicating the script part in the language injections settings in 11.1 ultimate, and adding aui as a prefix but it didn't work.

Is there any way to do this?

Thanks!!
19 comments
Comment actions Permalink

Hello.

What is the definition of "aui" namespace prefix? Do I need some library to download?

Thank you,
Alexander.

0
Comment actions Permalink

I never saw that you replied to this, I'm terribly sorry for the extreme delay.

You can see the taglib here: https://github.com/liferay/liferay-portal/blob/master/util-taglib/src/META-INF/aui.tld

You can see the actual code, here: https://github.com/liferay/liferay-portal/tree/master/util-taglib/src/com/liferay/taglib/aui

You can see where the script tag gets injected, here: https://github.com/liferay/liferay-portal/blob/master/util-taglib/src/com/liferay/taglib/aui/ScriptTag.java around line 202 as of this posting.

0
Comment actions Permalink

Hello.

The file where you're trying to get proper script element: is it jsp or html (or anything)?

Thank you,
Alexander.

0
Comment actions Permalink

Usually JSP files is where I'd try it, occasionally a JSPF

0
Comment actions Permalink

I've managed to get proper highlighting inside aui:script in a jsp file the following way:

1. Added liferay's util-taglib.jar to the module's depenencies.
2. In the jsp file provided the declaration of aui prefix (mapped to http://alloy.liferay.com/tld/aui).
3. In Settings / Language Injections copied xml:script element (it's bundled, find it) and in the properties of the copy set http://alloy.liferay.com/tld/aui namespace.

Please try.

Regards,
Alexander.

0
Comment actions Permalink

Trying now!!! *HOPE*

0
Comment actions Permalink

Didn't work :( If it matters, I'm on IJ 12 now.

Here are screenshots



This is the file I tested:
(I also tried <%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui" %>)
https://dl.dropbox.com/u/2220830/intellij/file-testing.png

Here is the file after reformatting code:

https://dl.dropbox.com/u/2220830/intellij/file-reformatted.png

You can see it's lost all indenting, and the colors aren't right.

Here is my language injections:

https://dl.dropbox.com/u/2220830/intellij/aui-settings.png

and my module settings:

https://dl.dropbox.com/u/2220830/intellij/module-settings.png

0
Comment actions Permalink

Your code sample refers to http://liferay.com/tld/aui, while the injection settings refers to http://alloy.liferay.com/tld/aui. Make them the same, please.

Alexander.

0
Comment actions Permalink

Fixed, I had fixed it before and did upload the right screenshot. Here is the correct screenshot.


I also made a youtube video of it, which you can see HERE: http://www.youtube.com/watch?v=ERbtvExFhCU
https://dl.dropbox.com/u/2220830/intellij/latest-before-reformat.png

https://dl.dropbox.com/u/2220830/intellij/latest-after-reformat.png

0
Comment actions Permalink

Given your screenshot, it does not look that Javascript language
injection took place (JavaScript plugin should be enabled btw)

On 2/6/2013 7:53 AM, Brett Swaim wrote:

Fixed, I had fixed it before and did upload the right screenshot. Here is the correct screenshot.

>
>

I also made a youtube video of it, which you can see HERE: http://www.youtube.com/watch?v=ERbtvExFhCU
  Image:https://dl.dropbox.com/u/2220830/intellij/latest-before-reformat.png

>

  Image:https://dl.dropbox.com/u/2220830/intellij/latest-after-reformat.png

>

---
Original message URL: http://devnet.jetbrains.net/message/5478206#5478206

>

0
Comment actions Permalink

Did you see my youtube video, here: http://www.youtube.com/watch?v=ERbtvExFhCU

What part of the injection did I do incorrectly?

0
Comment actions Permalink

Providing the plugin is enabled (please, re-check it), and injection is configured, I have no idea, why it can't work. For me it does.
Can you try new small test project? If it does not work for it too, could you attach it?

Thank you,
Alexander.

0
Comment actions Permalink

when you say make sure the plugin is enabled, do you mean this?

https://dl.dropbox.com/u/2220830/intellij/plugins.png

0
Comment actions Permalink

EDIT:

After some playing, I see that the cause is: var uri = "<%=ajaxUrl%>?cache=" + new Date().getTime();


if I remove that, everything formats perfectly. I look forward to your thoughts!

Original:

Progress!! It code highlights now!! So good!

Okay, the last problem is that it's still not indenting. Try this, in your project paste:


<aui:script use="aui-io-request,aui-parse-content">
 var form = A.one('.question-display-container');

 form.plug(A.Plugin.ParseContent);

 var uri = "<%=ajaxUrl%>?cache=" + new Date().getTime();

 var request = A.io.request(uri, {
 on: {
 success: function () {
 var indicator = A.one('#loading-indicator');
 if (indicator) {
 indicator.remove();
 }
 A.all('.aui-widget.aui-component.aui-rating.aui-thumbrating').remove();
 form.setContent(this.get('responseData'));
 setTimeout(function () {
 request.start();
 }, 1500);
 }
 }
 });
</aui:script>


and


<script>
 var form = A.one('.question-display-container');

 form.plug(A.Plugin.ParseContent);

 var uri = "<%=ajaxUrl%>?cache=" + new Date().getTime();

 var request = A.io.request(uri, {
 on: {
 success: function () {
 var indicator = A.one('#loading-indicator');
 if (indicator) {
 indicator.remove();
 }
 A.all('.aui-widget.aui-component.aui-rating.aui-thumbrating').remove();
 form.setContent(this.get('responseData'));
 setTimeout(function () {
 request.start();
 }, 1500);
 }
 }
 });
</script>



Do they format the same?

This is what I see:

https://dl.dropbox.com/u/2220830/intellij/indenting.png

0
Comment actions Permalink

Thank you for your patience.

The formatting is really a problem. I've created this one: http://youtrack.jetbrains.com/issue/IDEA-100870
Please watch and comment.

Alexander.

0
Comment actions Permalink

I have managed to inject javascript for <aui:script> tags as explained in this discussion.
However, after weeks of use with no issue (other than the formating issue), I have lost my injections, and reinserting them doesn't work.

I assume my injection settings have been somehow corrupted. Can somebody tell me how to reset the custom injections ?

Thanks and best regards,
Alain

0
Comment actions Permalink

As a first step, please recheck Settings / Language Injections.

Regards,
Alexander.

0

Please sign in to leave a comment.