Reputation: 4430
Atom snippet syntax looks simple when setting the scope to files that end in a specific extension, but I was hoping to define the scope to inside something like this:
<script type="text/x-template" id="#open-deposit-checker">
... I would like HTML snippets to work in here ...
</script>
In my snippets file I thought I could do this to make it work everywhere, but it doesn't seem to work. I would really like to know how to do snippet scoping properly:
'*':
'Heading 1':
'prefix': 'h1'
'body': '<h1>$1</h1>$0'
Upvotes: 1
Views: 186
Reputation: 10563
The Atom Snippets package does not support this feature.
At the moment, the scopes are defined by file type and available grammars but you can't extend it for example like you can with CSS selectors.
If you take a look at the language-html
grammar used in Atom, the closest scope you'll be able to get is source.js.embedded.html
. It defines a script tag embedded in an HTML file. Unfortunately, you won't be able to get the text/x-template
filtered on your scope without altering this grammar.
There is also a little feature in Atom that can give you your current scope at any time which will save you some time. You can at any time bring the Command Palette using Cmd-Shift-p and run the Editor: Log Cursor Scope
command. It'll trigger a notification containing a list of the current scopes.
For example, in your case, you'll get:
The source.js.embedded.html
scope is indeed the closer in this case.
Upvotes: 1