Last Updated: February 25, 2016
· rooftopsparrow

Script tag highlighting for TextMate and Sublime Text

TextMate by default will highlight anything in a script tag as javascript.
But for Backbone.js and other javascript MVC frameworks, the script tag is used as a template container. So this will remove javascript highlighting and use html highlighting instead for any

<script type="text/template">

Replace this line in the Bundle Editor for HTML language:

begin = '(?:^\s+)?(<)((?i:script))\b(?![^>]*/>)';

with this line:

begin = '(?:^\s+)?(<)((?i:script))\b(?!([^>]*text/template[^>]*|[^>]*/>))';

This also works for SublimeText 2.


2 Responses
Add your response

hey where do u do this for sublime?

over 1 year ago ·

dont worry found it in xml HTML.tmLanguage, works perfectly just need to encode < with < etc :) THANKS

over 1 year ago ·