Easy mode: include
If your language really is just HTML, you can set up a simple package to handle this.
Create a package called langugage-ejs
and in grammars/ejs.cson
you can include HTML as having the patterns you care about:
'fileTypes': [
'ejs'
]
'name': 'Embedded JavaScript'
'patterns': [
{
'include': 'source.html'
}
]
'scopeName': 'source.ejs'
language-ipynb certainly does this by extending JSON.
What about my template tags?
In reality though, you have template tags on top of HTML that you would want to make the editor recognize. The best example I can find is for erb (Embedded Ruby templates). It sources from HTML but also adds on other tags as shown in this snippet:
...
'patterns': [
{
'begin': '<%+#'
'captures':
'0':
'name': 'punctuation.definition.comment.erb'
'end': '%>'
'name': 'comment.block.erb'
}
{
'begin': '<%+(?!>)[-=]?'
'captures':
'0':
'name': 'punctuation.section.embedded.ruby'
'end': '-?%>'
'name': 'source.ruby.rails.embedded.html'
'patterns': [
{
'captures':
'1':
'name': 'punctuation.definition.comment.ruby'
'match': '(#).*?(?=-?%>)'
'name': 'comment.line.number-sign.ruby'
}
{
'include': 'source.ruby.rails'
}
]
}
{
'include': 'text.html.basic'
}
]
...