I have a server side processor that interprets all blocks surrounded with %serversidejs% as javascript that is executed on the server before the HTML page is served up. For example:
<p>some text</p>
%serversidejs%
var temp = "a", "b", "c"];
for(var i=0; i < temp.length; i++)
print("<p>" + temp* + "</p>");
%serversidejs%
<p>some more text</p>
I was trying to emulate the handler in HTML.tmLanguage to get it to work, but can’t seem to get it to work. There are a few regular expressions that have unfamiliar syntax, in particular:
<key>end</key>
<string>(?<=</(script|SCRIPT))(>)(?:\s*\n)?</string>
<key>begin</key>
<string>(?<!</(?:script|SCRIPT))(>)</string>
I am not familiar with the (?<=< and (?<!< syntax in the above. Can anyone tell me what those are doing?
My next attempt was a very, very basic handler:
<dict>
<key>begin</key>
<string>(?:^\s+)?(%)((?i:serversidejs))\b(?!^%]*/%)</string>
<key>end</key>
<string>(%/(serversidejs))(%)(?:\s*\n)?</string>
<key>name</key>
<string>source.js.serversidejs.embedded.html</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>source.js</string>
</dict>
</array>
</dict>
<dict>
This shows javascript syntax highlighting and shows course.js.serversidejs.embedded.html when I hit Ctrl+Alt+Shift+P when inside a %serversidejs% block, however, the SublimeCodeIntel does not seem to pick it up as JavaScript. Any ideas how to get SublimeCodeIntel to recognize this block as JavaScript?*