Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime -- Setting Default Syntax for *.hbs.html

Tags:

sublimetext3

I've started working with MeteorJS, which requires Handlebars templates to end with *.html.

You can't use *.hbs, or Meteor will throw an error.

I'd like to simply use *.hbs.html, so Meteor won't raise an exception, and I'll get the syntax highlighting for Handlebars simultaneously. How can I customize Sublime to recognize *.hbs.html as Handlebars syntax?

UPDATE:

Here's my code for ApplySyntax (not working yet):

"syntaxes": [
      {
            "name": "Handlebars",
             "match": "all",
             "rules": [
                 {"file_name": ".hbs.html$"}
             ]
        }
    ]
like image 632
ilrein Avatar asked Feb 10 '23 23:02

ilrein


1 Answers

Try this in ApplySyntax:

"syntaxes": [
  {
    "name": "Handlebars/Handlebars",
    "extensions": ["hbs.html"]
  }
]

The key is in the name - you need to specify the name of the package AND the path to the .tmLanguage file (extension excluded) within that package. I think it's in the root of the Handlebars package in this case, so this should work.

If you need other extensions just add them to that array, or if you need more complex matching you can use regular expressions as outlined in the other answer (or a combination of both).

like image 87
Inkling Avatar answered Mar 07 '23 16:03

Inkling