Formatting "text/form-script" as javascript in intelliJ

Hi all! :slight_smile:

I have a very simple question regarding code formatting in IntelliJ.
My embedded forms have a great deal of javascript code in inline text/form-script script tags. It does not get associated with javascript which is becoming more and more of a nuisance. I know lots of people are using IntelliJ and perhaps someone was smart enough to get it recognised as such. Any hints/tips/tricks are appreciated :smiley:

I’m using IntelliJ Ultimate 2016.1

Kind regards!

I finally found it :dizzy_face:
Select all the code you want to have recognised. A balloon message will pop-up (can be forced with a shortcut key) showing ‘Inject language or reference’. Click it -> select Javascript.

This will format is as Javascript but it will have a rather annoying background color so this is still not workable.
Go to Preferences -> Editor -> Colors & Fonts -> General
Select Code -> Injected language fragment. De-select the background colour and click save.

Eclipse has the same highlighting issue. Does anybody have a workaround here? Why is this script type needed anyway?

I don’t have a workaround for Eclipse, but I can answer the question why we don’t use text/javascript or application/javascript:

The reason is, that we don’t want the browser to execute the provided script when it is loaded. If it would be a script tag and have a type that the browser recognizes as normal Javascript, it would execute it. But then some features would be missing (e.g. the angular $scope variable would not be set), as we need to perform some magic to make $scope, camForm and inject available in the embedded form script.

So instead of letting the browser naively execute it without any context, we take care of preparing the environment for the script to execute it.