as HTML I have been working a lot with knockout patterns lately and I use Sublime for this. ...">

Make Sublime Text handle <script type = "text / html"> as HTML

I have been working a lot with knockout patterns lately and I use Sublime for this. one thing i noticed is that when using a template that needs to be defined in a block like this:

<script type="text/html"></script> 

it treats the content as Javascript, which means that I am missing a lot of the HTML tools that I installed. I would like it to treat this content as HTML instead of Javascript; are there any settings i could use for this?

+6
source share
2 answers

I managed to find the answer thanks iamntz here ; the trick is simple. For Sublime Text 3:

  • Open Packages in the installation directory, then find the HTML.sublime package and open it in 7zip (or in your favorite archive tool).
  • Find HTML.tmLanguage and open it for editing
  • Find this line:

     <string>(?:^\s+)?(&lt;)((?i:script))\b(?![^&gt;]*/&gt;)</string> 

    and replace it with this:

     <string>(?:^\s+)?(&lt;)((?i:script))\b(?!([^&gt;]*text/html[^&gt;]*|[^&gt;]*/>))</string> 

Nice and easy; text / html in the second fragment can be replaced with any type of template, and now it will be read as HTML by Sublime. This fix will also work with any HTML packages that you have installed.

+18
source

This is no longer required for Sublime Text 3 build 3103. Just make sure that the script tag type tag starts with "text /" and doesn't end with "javascript", and it should now correctly process the HTML.

0
source

Source: https://habr.com/ru/post/947503/


All Articles