diff --git a/snippets/meteor-api-snippets-javascript.cson b/snippets/meteor-api-snippets-javascript.cson index d9d91fc..2264eb1 100644 --- a/snippets/meteor-api-snippets-javascript.cson +++ b/snippets/meteor-api-snippets-javascript.cson @@ -38,7 +38,7 @@ 'function()': 'prefix': 'f' - 'body': 'function(${1:argument}){\n\t${2:}\n},' + 'body': 'function(${1:argument}) {\n\t${2:}\n},' #=================================================== @@ -46,19 +46,19 @@ 'Meteor.isClient': 'prefix': 'isClient' - 'body': 'if(Meteor.isClient){\n\t${1:}\n}' + 'body': 'if (Meteor.isClient) {\n\t${1:}\n}' 'Meteor.isServer': 'prefix': 'isServer' - 'body': 'if(Meteor.isServer){\n\t${1:}\n}' + 'body': 'if (Meteor.isServer) {\n\t${1:}\n}' 'Meteor.isCordova': 'prefix': 'isCordova' - 'body': 'if(Meteor.isCordova){\n\t${1:}\n}' + 'body': 'if (Meteor.isCordova) {\n\t${1:}\n}' 'Meteor.startup': 'prefix': 'startup' - 'body': 'Meteor.startup(function(){\n\t${1:}\n});' + 'body': 'Meteor.startup(function() {\n\t${1:}\n});' 'Meteor.absoluteUrl': 'prefix': 'absolute' @@ -70,7 +70,7 @@ 'Meteor Publish': 'prefix': 'publish' - 'body': 'Meteor.publish("${1:name}", function(${2:argument}){\n\t${3:}\n});' + 'body': 'Meteor.publish("${1:name}", function(${2:argument}) {\n\t${3:}\n});' 'Meteor Subscribe': 'prefix': 'subscribe' @@ -83,7 +83,7 @@ 'Meteor Methods': 'prefix': 'methods' 'body': 'Meteor.methods({ - \n\t${1:methodName}:function(){ + \n\t${1:methodName}: function() { \n\t\t${2:} \n\t} \n});' @@ -95,11 +95,11 @@ 'Meteor.call': 'prefix': 'call' - 'body': 'Meteor.call("${1:meteorMethod}", ${2:dataObject}, function(error, result){ - \n\tif(error){ + 'body': 'Meteor.call("${1:meteorMethod}", ${2:dataObject}, function(error, result) { + \n\tif (error) { \n\t\tconsole.log("error", error); \n\t} - \n\tif(result){ + \n\tif (result) { \n\t\t${3:} \n\t} \n});' @@ -125,7 +125,7 @@ 'Meteor.onConnection': 'prefix': 'onConnection' - 'body': 'Meteor.onConnection(function(){ + 'body': 'Meteor.onConnection(function() { \n\t${1:} \n});' @@ -143,7 +143,7 @@ 'Collection.findOne': 'prefix': 'findOne' - 'body': '${1:Collection}.findOne({_id:"${2:recordId}"${3:}});\n${4:}' + 'body': '${1:Collection}.findOne({_id: "${2:recordId}"${3:}});\n${4:}' 'Collection.insert': 'prefix': 'insert' @@ -160,18 +160,18 @@ 'Collection.remove': 'prefix': 'remove' - 'body': '${1:Collection}.remove({_id:"${2:recordId}"${3:}});\n${4:}' + 'body': '${1:Collection}.remove({_id: "${2:recordId}"${3:}});\n${4:}' 'Collection.allow': 'prefix': 'allow' 'body': '${1:Collection}.allow({ - \n\tinsert: function(){ + \n\tinsert: function() { \n\t\treturn ${2:true}; \n\t}, - \n\tupdate: function(){ + \n\tupdate: function() { \n\t\treturn ${3:true}; \n\t}, - \n\tremove: function(){ + \n\tremove: function() { \n\t\treturn ${4:true}; \n\t} \n});\n${5:}' @@ -179,13 +179,13 @@ 'Collection.deny': 'prefix': 'deny' 'body': '${1:Collection}.deny({ - \n\tinsert: function(){ + \n\tinsert: function() { \n\t\treturn ${2:false}; \n\t}, - \n\tupdate: function(){ + \n\tupdate: function() { \n\t\treturn ${3:false}; \n\t}, - \n\tremove: function(){ + \n\tremove: function() { \n\t\treturn ${4:false}; \n\t} \n});\n${5:}' @@ -195,13 +195,13 @@ 'prefix': 'Collection' 'body': '${1:CollectionName} = new Mongo.Collection("${2:name}"); \n${3:CollectionName}.allow({ - \n\tinsert: function(){ + \n\tinsert: function() { \n\t\treturn ${4:true}; \n\t}, - \n\tupdate: function(){ + \n\tupdate: function() { \n\t\treturn ${5:true}; \n\t}, - \n\tremove: function(){ + \n\tremove: function() { \n\t\treturn ${6:true}; \n\t} \n});\n${7:}' @@ -247,17 +247,17 @@ 'body': 'Meteor.loggingIn()' 'Meteor.logout': 'prefix': 'logout' - 'body': 'Meteor.logout(function(){ + 'body': 'Meteor.logout(function() { \n\t${1:} \n});' 'Meteor.logoutOtherClients': 'prefix': 'logoutOtherClients' - 'body': 'Meteor.logoutOtherClients(function(){ + 'body': 'Meteor.logoutOtherClients(function() { \n\t${1:} \n});' 'Meteor.loginWithPassword': 'prefix': 'logoutOtherClients' - 'body': 'Meteor.logoutOtherClients(${1:user}, ${2:password}, function(){ + 'body': 'Meteor.logoutOtherClients(${1:user}, ${2:password}, function() { \n\t${3:} \n});' @@ -282,24 +282,24 @@ 'Accounts.validateNewUser': 'prefix': 'validateNewUser' - 'body': 'Meteor.validateNewUser(function(){ + 'body': 'Meteor.validateNewUser(function() { \n\t${1:} \n});' 'Accounts.onCreateUser': 'prefix': 'onCreateUser' - 'body': 'Meteor.onCreateUser(function(options, user){ + 'body': 'Meteor.onCreateUser(function(options, user) { \n\t${1:} \n\treturn ${1:user} \n});' 'Accounts.onLogin': 'prefix': 'onLogin' - 'body': 'Meteor.onLogin(function(){ + 'body': 'Meteor.onLogin(function() { \n\t${1:} \n});' 'Accounts.onLoginFailure': 'prefix': 'onLoginFailure' - 'body': 'Meteor.onLoginFailure(function(){ + 'body': 'Meteor.onLoginFailure(function() { \n\t${1:} \n});' @@ -317,22 +317,22 @@ \n\tpassword: "${1:password}" \n}; \n - \nAccounts.createUser(${1:userObject}, function(){ + \nAccounts.createUser(${1:userObject}, function() { \n\t${1:} \n});' 'Accounts.changePassword': 'prefix': 'changePassword' - 'body': 'Accounts.changePassword(${1:oldPassword}, ${2:newPassword}, function(){ + 'body': 'Accounts.changePassword(${1:oldPassword}, ${2:newPassword}, function() { \n\t${1:} \n});' 'Accounts.forgotPassword': 'prefix': 'forgotPassword' - 'body': 'Accounts.forgotPassword({email: "${1:address}"}, function(){ + 'body': 'Accounts.forgotPassword({email: "${1:address}"}, function() { \n\t${2:} \n});' 'Accounts.resetPassword': 'prefix': 'resetPassword' - 'body': 'Accounts.resetPassword(${1:token}, ${2:newPassword}, function(){ + 'body': 'Accounts.resetPassword(${1:token}, ${2:newPassword}, function() { \n\t${3:} \n});' 'Accounts.setPassword': @@ -340,7 +340,7 @@ 'body': 'Accounts.setPassword(${1:userId}, ${2:newPassword});' 'Accounts.verifyEmail': 'prefix': 'verifyEmail' - 'body': 'Accounts.verifyEmail(${1:token}, function(){ + 'body': 'Accounts.verifyEmail(${1:token}, function() { \n\t${1:} \n});' 'Accounts.sendResetPasswordEmail': @@ -374,13 +374,13 @@ 'Meteor.setTimeout': 'prefix': 'setTimeout' - 'body': 'Meteor.setTimeout(function(){ + 'body': 'Meteor.setTimeout(function() { \n\t${2:} \n}, ${1:milliseconds});' 'Meteor.setInterval': 'prefix': 'setInterval' - 'body': 'Meteor.setInterval(function(){ + 'body': 'Meteor.setInterval(function() { \n\t${2:} \n}, ${1:milliseconds});' @@ -398,7 +398,7 @@ 'Tracker.autorun': 'prefix': 'autorun' - 'body': 'Tracker.autorun(function(){ + 'body': 'Tracker.autorun(function() { \n\t${2:} \n});' @@ -408,19 +408,19 @@ 'Tracker.nonreactive': 'prefix': 'nonreactive' - 'body': 'Tracker.nonreactive(function(){ + 'body': 'Tracker.nonreactive(function() { \n\t${2:} \n});' 'Tracker.onInvalidate': 'prefix': 'onInvalidate' - 'body': 'Tracker.onInvalidate(function(){ + 'body': 'Tracker.onInvalidate(function() { \n\t${2:} \n});' 'Tracker.afterFlush': 'prefix': 'afterFlush' - 'body': 'Tracker.afterFlush(function(){ + 'body': 'Tracker.afterFlush(function() { \n\t${2:} \n});' @@ -438,13 +438,13 @@ 'Template Rendered': 'prefix': 'rendered' - 'body': 'Template.${1:name}.onRendered(function(){\n\t${2}\n});' + 'body': 'Template.${1:name}.onRendered(function() {\n\t${2}\n});' 'Template Events': 'prefix': 'events' 'body': ' Template.${1:name}.events({ - \n\t"click ${2:#event}": function(event, template){ + \n\t"click ${2:#event}": function(event, template) { \n\t\t${3:} \n\t} \n}); @@ -452,7 +452,7 @@ 'Template Created': 'prefix': 'created' 'body': ' - Template.${1:name}.onCreated(function(){ + Template.${1:name}.onCreated(function() { \n\t${2:} \n}); ' @@ -460,7 +460,7 @@ 'Template Destroyed': 'prefix': 'destroyed' 'body': ' - Template.${1:name}.onDestroyed(function(){ + Template.${1:name}.onDestroyed(function() { \n\t${2:} \n}); ' @@ -468,19 +468,19 @@ 'Template': 'prefix': 'Template' 'body': ' - \nTemplate.${1:name}.helpers({ - \n\tcreate: function(){ + Template.${1:name}.helpers({ + \n\tcreate: function() { \n\t\t${2:} \n\t}, - \n\trendered: function(){ + \n\trendered: function() { \n\t\t${3:} \n\t}, - \n\tdestroyed: function(){ + \n\tdestroyed: function() { \n\t\t${4:} \n\t}, \n}); \n\nTemplate.${9:name}.events({ - \n\t"${5:click #foo}": function(event, template){ + \n\t"${5:click #foo}": function(event, template) { \n\t\t${6:} \n\t} \n}); @@ -489,11 +489,11 @@ 'Template Helpers': 'prefix': 'helpers' - 'body': 'Template.${1:name}.helpers({\n\trendered: function(){\n\t\t${2}\n\t}\n});' + 'body': 'Template.${1:name}.helpers({\n\trendered: function() {\n\t\t${2}\n\t}\n});' 'Template.registerHelper': 'prefix': 'registerHelper' - 'body': 'Template.registerHelper("${1:helperName}", function(${2:argument}){\n\t${3}\n});' + 'body': 'Template.registerHelper("${1:helperName}", function(${2:argument}) {\n\t${3}\n});' #=================================================== @@ -555,51 +555,51 @@ 'HTTP Call': 'prefix': 'httpcall' - 'body': 'HTTP.call("${1:meteorMethod}", function(error, result){ - \n\tif(error){ + 'body': 'HTTP.call("${1:meteorMethod}", function(error, result) { + \n\tif (error) { \n\t\tconsole.log("error", error); \n\t} - \n\tif(result){ + \n\tif (result) { \n\t\t${2:} \n\t} \n});' 'HTTP Get': 'prefix': 'httpget' - 'body': 'HTTP.get("${1:meteorMethod}", function(error, result){ - \n\tif(error){ + 'body': 'HTTP.get("${1:meteorMethod}", function(error, result) { + \n\tif (error) { \n\t\tconsole.log("error", error); \n\t} - \n\tif(result){ + \n\tif (result) { \n\t\t${2:} \n\t} \n});' 'HTTP.post': 'prefix': 'httppost' - 'body': 'HTTP.post("${1:meteorMethod}", ${2:dataObject}, function(error, result){ - \n\tif(error){ + 'body': 'HTTP.post("${1:meteorMethod}", ${2:dataObject}, function(error, result) { + \n\tif (error) { \n\t\tconsole.log("error", error); \n\t} - \n\tif(result){ + \n\tif (result) { \n\t\t${3:} \n\t} \n});' 'HTTP.put': 'prefix': 'http.put' - 'body': 'HTTP.put("${1:meteorMethod}", ${2:dataObject}, function(error, result){ - \n\tif(error){ + 'body': 'HTTP.put("${1:meteorMethod}", ${2:dataObject}, function(error, result) { + \n\tif (error) { \n\t\tconsole.log("error", error); \n\t} - \n\tif(result){ + \n\tif (result) { \n\t\t${3:} \n\t} \n});' 'HTTP.del': 'prefix': 'httpdel' - 'body': 'HTTP.del("${1:meteorMethod}", function(error, result){ - \n\tif(error){ + 'body': 'HTTP.del("${1:meteorMethod}", function(error, result) { + \n\tif (error) { \n\t\tconsole.log("error", error); \n\t} - \n\tif(result){ + \n\tif (result) { \n\t\t${2:} \n\t} \n});' @@ -614,7 +614,7 @@ 'prefix': 'Email' 'body': 'Email.send({ \n\tfrom: "${1:sender@somewhere.net}", - \nif(result){ + \nif (result) { \n\t\t${2:} \n\t} \n});' @@ -646,20 +646,20 @@ 'Assets.getText': 'prefix': 'getText' - 'body': 'Assets.getText("${1:assetPath}", function(error, result){ - \n\tif(error){ + 'body': 'Assets.getText("${1:assetPath}", function(error, result) { + \n\tif (error) { \n\t\tconsole.log("error", error); \n\t} - \n\tif(result){ + \n\tif (result) { \n\t\t${2:} \n\t} \n});' 'Assets.getBinary': 'prefix': 'getBinary' - 'body': 'Assets.getBinary("${1:assetPath}", function(error, result){\n\tif(error){ + 'body': 'Assets.getBinary("${1:assetPath}", function(error, result) {\n\tif (error) { \n\t\tconsole.log("error", error); \n\t} - \n\tif(result){ + \n\tif (result) { \n\t\t${2:} \n\t} \n});' @@ -672,9 +672,9 @@ 'prefix': 'configure' 'body': ' Router.configure({ - \n\tlayoutTemplate:"${1:layoutTemplate}", - \n\tnotFoundTemplate:"${2:notFoundTemplate}", - \n\tloadingTemplate:"${3:loadingTemplate}", + \n\tlayoutTemplate: "${1:layoutTemplate}", + \n\tnotFoundTemplate: "${2:notFoundTemplate}", + \n\tloadingTemplate: "${3:loadingTemplate}", \n\tyieldRegions:{ \n\t\t"${4:myAside}": {to: "aside"}, \n\t\t"${5:myHeader}": {to: "header"}, @@ -685,7 +685,7 @@ 'Router': 'prefix': 'Router' 'body': ' - Router.route("${1:routePath}", function(){ + Router.route("${1:routePath}", function() { \n\tthis.layout("${2:ApplicationLayout}"); \n\tthis.render("${5:PostHeader}", {to: "header"}); \n\tthis.render("${4:PostAside}", {to: "aside"}); @@ -697,24 +697,24 @@ 'prefix': 'route' 'body': ' Router.route("${1:routePath}", { - \n\tname:"${2:routeName}", - \n\ttemplate:"${3:templateName}", - \n\twaitOn:function(){ + \n\tname: "${2:routeName}", + \n\ttemplate: "${3:templateName}", + \n\twaitOn: function() { \n\t\t${4:subscriptions} \n\t}, - \n\tdata:function(){ + \n\tdata: function() { \n\t\t${5: dataFunction} \n\t}, - \n\tonBeforeAction:function(){ + \n\tonBeforeAction: function() { \n\t\t${6} \n\t}, - \n\tonAfterAction:function(){ + \n\tonAfterAction: function() { \n\t\t${7} \n\t}, - \n\tonRun:function(){ + \n\tonRun: function() { \n\t\t${8} \n\t}, - \n\tonReRun:function(){ + \n\tonReRun: function() { \n\t\t${9} \n\t} \n}); @@ -723,22 +723,22 @@ 'prefix': 'UpsertRoute' 'body': ' Router.route("/add/${1:routePath},"{ - \n\tname:"${2:routeName}", - \n\ttemplate:"${3:routeTemplate}" + \n\tname: "${2:routeName}", + \n\ttemplate: "${3:routeTemplate}" \n}); Router.route("/edit/${1:routePath}/:${4:paramId},"{ - \n\tname:"${2:routeName}", - \n\ttemplate:"${3:routeTemplate}" - \n\tdata:function(){ + \n\tname: "${2:routeName}", + \n\ttemplate: "${3:routeTemplate}" + \n\tdata: function() { \n\t\treturn ${5: collectionName}.findOne({_id: this.params.${4:paramId}}); \n\t}, - \n\tonBeforeAction:function(){ + \n\tonBeforeAction: function() { \n\t\tSession.set("${7}", this.params.${4:paramId}}); \n\t\t${8} \n\t\tthis.next(); \n\t}, - \n\tonAfterAction:function(){ + \n\tonAfterAction: function() { \n\t\t${9} \n\t}, \n}); @@ -752,17 +752,17 @@ 'prefix': 'page' 'body': ' Router.route("${1:routePath}", { - \n\tname:"${2:routeName}", - \n\ttemplate:"${3:templateName}" + \n\tname: "${2:routeName}", + \n\ttemplate: "${3:templateName}" \n}); \n \nTemplate.${4:pageTemplate}.helpers({ - \n\trendered: function(){ + \n\trendered: function() { \n\t\t${5:} \n\t} \n}); \n\nTemplate.${4:pageTemplate}.events({ - \n\t"${6:click} #${7:elementId}": function(event, template){ + \n\t"${6:click} #${7:elementId}": function(event, template) { \n\t\t${8} \n\t} \n});