Sublime Forum

Snippet won't work

#1

This is what I’m passing in the file

[code]
<![CDATA[
/* Self Invoking Function. Will start the app as soon as the script finish loading */
(function(){
window.App = {
Models: {},
Collections: {},
Views: {},
Router: {}
};

// Global constants
window.ENTER_KEY = 13;

// Event object. Can trigger and listen for events with vent.trigger(…) and vent.on(…)
window.vent = _.extend({}, Backbone.Events);

// Helper Functions
window.template = function(id) {
return _.template( $(’#’ + id).html() );
}
})();
]]>

ba

[/code]

I’m saving it as backbone-app.sublime-snippet.
What happens is, when I digit “ba”, the snippet appear in the selection pop-over, then I press enter and it doesn’t show up (and the selection pop-over closes).

Please try to reproduce and check if it does work for you.
If not, what do you think is causing the issue?
Thank you guys for the support.

0 Likes

#2

really, no one?

0 Likes

#3

This was weird, but I figured it out. you need to escape the ‘$’ sign in your snippet, which subl uses to check for variables. Like this:

<snippet>
  <content><![CDATA[
/* Self Invoking Function. Will start the app as soon as the script finish loading */
(function(){
  window.App = {
    Models: {},
    Collections: {},
    Views: {},
    Router: {}
  };
  
  //  Global constants
  window.ENTER_KEY = 13;

  // Event object. Can trigger and listen for events with vent.trigger(...) and vent.on(...)
  window.vent = _.extend({}, Backbone.Events);
  
  // Helper Functions
  window.template = function(id) {
    return _.template( \$('#' + id).html() );
  }
})();
]]></content>
  <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
  <tabTrigger>ba</tabTrigger>
  <!-- Optional: Set a scope to limit where the snippet will trigger -->
  <!-- <scope>source.python</scope> -->
</snippet>

Then it should work as intended.

0 Likes