Sammy.Application use ( )
use() is the entry point for including Sammy plugins.
The first argument to use should be a function() that is evaluated
in the context of the current application, just like the app_function
argument to the Sammy.Application constructor.
Any additional arguments are passed to the app function sequentially.
For much more detail about plugins, check out: http://sammyjs.org/docs/plugins
Example
var MyPlugin = function(app, prepend) {
this.helpers({
myhelper: function(text) {
alert(prepend + " " + text);
}
});
};
var app = $.sammy(function() {
this.use(MyPlugin, 'This is my plugin');
this.get('#/', function() {
this.myhelper('and dont you forget it!');
//=> Alerts: This is my plugin and dont you forget it!
});
});
If plugin is passed as a string it assumes your are trying to load Sammy."Plugin". This is the prefered way of loading core Sammy plugins as it allows for better error-messaging.
Example
$.sammy(function() {
this.use('Mustache'); //=> Sammy.Mustache
this.use('Storage'); //=> Sammy.Storage
});