Skip to content

Instantly share code, notes, and snippets.

@teaholiday89
Created April 2, 2013 06:45
Show Gist options
  • Save teaholiday89/5290365 to your computer and use it in GitHub Desktop.
Save teaholiday89/5290365 to your computer and use it in GitHub Desktop.
jQuery Plugin Boilerplate
<snippet>
<content><![CDATA[
/*
* jQuery ${1:plugin} Plugin
*
* ${2:Description}
*
*/
;(function(\$, window, undefined) {
var defaults = {
${0}
}
var methods = {
}
\$.${1} = function(method, options) {
var options = \$.extend({}, defaults, options);
if (methods[method]) {
return methods[method].apply(null, options);
}
else if ( typeof method === 'object' ) {
var settings = method;
methods.init.apply(null, settings);
}
else {
\$.error("Method " + method + " is not a defined in jQuery ${1:plugin");
}
}
})(jQuery, window);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>jqplugin</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment