Sublime Forum

Snippet error: Empty key

#1

I downloaded some jQuery snippets and upon starting Sublime I get the following errors:

[code]Error parsing content for snippet Packages/Javascript/$_get.sublime-snippet: Empty key

Error parsing content for snippet Packages/Javascript/$_getIfModifed.sublime-snippet: Empty key[/code]

Here is the code for those snippets

<snippet> <content><![CDATA[\$.get('${1:/test/ajax-test.xml}'${2/(.+)/(?1:, function\(xml\){ :)/}${2:alert( $("title",xml).text() )//optional stuff to do after get}${2/(.+)/(?1:; }:)/}); $0]]></content> <tabTrigger>$.get</tabTrigger> <scope>source.js.jquery</scope> <description>$.get</description> </snippet>

<snippet> <content><![CDATA[\$.getIfModified('${1:/test/test.cgi}'${3/(.+)/(?1:, function\(data\){ :)/}${3:alert( $"Data loaded: " + data )//optional stuff to do after get}${3/(.+)/(?1:; }:)/}); $0]]></content> <tabTrigger>$.getIfModified</tabTrigger> <scope>source.js.jquery</scope> <description>$.getIfModified</description> </snippet>

I’ve never made changes to snippet files before, so I’m not exactly sure what is wrong with the syntax. Can anyone tell me what the “key” is that its referring to that is empty or missing?

0 Likes

#2

Looks like a \ was missing before $:

<snippet> <content><![CDATA[\$.get('${1:/test/ajax-test.xml}'${2/(.+)/(?1:, function\(xml\){ :)/}${2:alert( \$("title",xml).text() )//optional stuff to do after get}${2/(.+)/(?1:; }:)/}); $0]]></content> <tabTrigger>$.get</tabTrigger> <scope>source.js.jquery</scope> <description>$.get</description> </snippet>

<snippet> <content><![CDATA[\$.getIfModified('${1:/test/test.cgi}'${3/(.+)/(?1:, function\(data\){ :)/}${3:alert( \$"Data loaded: " + data )//optional stuff to do after get}${3/(.+)/(?1:; }:)/}); $0]]></content> <tabTrigger>$.getIfModified</tabTrigger> <scope>source.js.jquery</scope> <description>$.getIfModified</description> </snippet>

2 Likes

#3

Thanks, Shoozza - 5 years after your post, people are still benefitting from it :smile:

1 Like

#4

Thank you very much!

1 Like

#5

correction… 10 years later… :slight_smile:

1 Like