Batman.js is no longer in production at Shopify and is not actively maintained.

This website is left for reference (and for old times' sake).


ControllerDirectory extends Batman.Object and it is defined in the scope of Batman.Dispatcher. A ControllerDirectory instance looks up controller instances (Batman.Controller.sharedController) by their instance names:

controllerDirectory.get('blogPosts') # => <BlogPostsController>

This functionality is implemented in ControllerDirectory's default accessor. You can access your app's controller directory at:

MyApp.get('controllers') # => <ControllerDirectory>
  • __app : App

    Returns the Batman.App passed to the constructor by Batman.Dispatcher.

  • Default Accessor

    A ControllerDirectory's default accessor returns controller instances by looking them up on its __app. The key will be capitalized and interpolated into #{key}Controller:

    controllerDirectory.get('blogPosts') # => <BlogPostsController>

Help us improve our documentation!

Contributions to this page are welcome on Github. If you find a problem but you cannot fix it, please open an issue.

Discussion regarding batman.js documentation is also welcome on our mailing list.