Sublime Text 2 recognize underscore templates as HTML

前端 未结 4 1929
南方客
南方客 2020-12-22 23:05

So, i\'m using underscore.js templates, in which i have to put my html template inside a script tag, like this



        
4条回答
  •  长情又很酷
    2020-12-22 23:20

    For those of us using Sublime Text 3

    I thought I'd consolidate the information into something easier to find, since none of the answers or comments directly gave me the solution I needed. Matt York's answer is mostly correct, but Shane N's solution is a bit more flexible:

    (?:^\s+)?(<)((?i:script))\b(?![^>]*/>)(?!.*type=["']text/(temp‌​late|html)['"])

    You can find HTML.sublime-package inside C:\Program Files\Sublime Text 3\Packages, as mentioned by PAEz.

    Instructions

    1. Extract HTML.sublime-package's contents like any normal zip file
    2. Inside the new /HTML directory you just created, open HTML.tmLanguage and modify the line mentioned above (probably line 286)
      1. It should come right after begin
    3. Save your changes, then add the /HTML directory that HTML.tmLanguage lives in to a new zip file
    4. Delete the old HTML.sublime-package file
    5. Change the filetype from .zip to .sublime-package (make sure Sublime isn't running while you do this)
    6. You should now be good to go - fire up Sublime and check out your awesome newly-highlighted templates!

提交回复
热议问题