Core

  1. Sammy

  2. Sammy.Application

    1. $element
    2. after
    3. any
    4. around
    5. before
    6. bind
    7. bindToAllEvents
    8. clearTemplateCache
    9. contextMatchesOptions
    10. del
    11. destroy
    12. error
    13. eventNamespace
    14. get
    15. getLocation
    16. helper
    17. helpers
    18. isRunning
    19. log
    20. lookupRoute
    21. mapRoutes
    22. notFound
    23. onComplete
    24. post
    25. put
    26. refresh
    27. routablePath
    28. route
    29. run
    30. runRoute
    31. setLocation
    32. setLocationProxy
    33. swap
    34. templateCache
    35. toString
    36. trigger
    37. unload
    38. use
  3. Sammy.DefaultLocationProxy

  4. Sammy.EventContext

    1. $element
    2. engineFor
    3. eventNamespace
    4. interpolate
    5. json
    6. load
    7. loadPartials
    8. notFound
    9. partial
    10. redirect
    11. render
    12. renderEach
    13. send
    14. swap
    15. toString
    16. trigger
  5. Sammy.Object

    1. escapeHTML
    2. has
    3. join
    4. keys
    5. log
    6. toHTML
    7. toHash
    8. toString
  6. Sammy.RenderContext

    1. appendTo
    2. collect
    3. interpolate
    4. load
    5. loadPartials
    6. next
    7. partial
    8. prependTo
    9. render
    10. renderEach
    11. replace
    12. send
    13. swap
    14. then
    15. trigger
    16. wait
  7. Sammy.addLogger

  8. Sammy.log

Plugins

  1. Sammy.Cache

  2. Sammy.DataCacheProxy

  3. Sammy.DataLocationProxy

  4. Sammy.EJS

  5. Sammy.Exceptional

  6. Sammy.Flash

  7. Sammy.Form

  8. Sammy.FormBuilder

  9. Sammy.GoogleAnalytics

  10. Sammy.Haml

  11. Sammy.Handlebars

  12. Sammy.Hogan

  13. Sammy.Hoptoad

  14. Sammy.JSON

  15. Sammy.KISSmetrics

  16. Sammy.Meld

  17. Sammy.MemoryCacheProxy

  18. Sammy.Mixpanel

  19. Sammy.Mustache

  20. Sammy.NestedParams

  21. Sammy.OAuth2

  22. Sammy.PathLocationProxy

  23. Sammy.Pure

  24. Sammy.PushLocationProxy

  25. Sammy.Session

  26. Sammy.Storage

  27. Sammy.Store

  28. Sammy.Store.Cookie

  29. Sammy.Store.Data

  30. Sammy.Store.LocalStorage

  31. Sammy.Store.Memory

  32. Sammy.Store.SessionStorage

  33. Sammy.Store.isAvailable

  34. Sammy.Template

  35. Sammy.Title

  36. Sammy.Tmpl

« Back

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 preferred 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
 });
comments powered by Disqus