nl_tokens: 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 : // code . quirkey . com / sammy / doc / plugins . html ### 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 } ) ;
pl_tokens: function ( ) { // flatten the arguments var args = _makeArray ( arguments ) , plugin = args . shift ( ) , plugin_name = plugin || '' ; try { args . unshift ( this ) ; if ( typeof plugin == 'string' ) { plugin_name = 'Sammy.' + plugin ; plugin = Sammy [ plugin ] ; } plugin . apply ( this , args ) ; } catch ( e ) { if ( typeof plugin === 'undefined' ) { this . error ( "Plugin Error: called use() but plugin (" + plugin_name . toString ( ) + ") is not defined" , e ) ; } else if ( ! _isFunction ( plugin ) ) { this . error ( "Plugin Error: called use() but '" + plugin_name . toString ( ) + "' is not a function" , e ) ; } else { this . <mask> ( "Plugin Error" , e ) ; } } return this ; }