Boilerplate application for the Chaplin.js library – written in plain JavaScript
Pull request Compare This branch is 47 commits behind chaplinjs:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Boilerplate Application for Chaplin.js

This is a boilerplate applicatoin built with Chaplin.js, an application structure on top of Backbone.js.

Running the Example

The original sources are written in CoffeeScript (coffee/ directory), but this repository already comes with the compiled JavaScripts (js/ directory). To recompile the CoffeeScripts, you might run the command line CoffeeScript compiler in the repository’s root directory:

coffee --bare --output js/ coffee/

An alternative version of the source, written in plain javascript, can be found in the plainjs/ directory. This may serve as a reference for developers who wish to use Chaplin without adding CoffeeScript to thier build-chain.

This repository also contains a copy of the Chaplin library in vendor/chaplin.js.

Architectural Documentation

Directory Structure

This example has a standard Chaplin MVC directory structure:

  • coffee/models
  • coffee/views
  • coffee/controllers
  • coffee/libs

All vendor libraries like jQuery and Backbone are located vendor/.

Application Startup

There are two special files which are responsible for the application bootstrap:

  • coffee/
  • coffee/ is the application root class which inherits from Chaplin.Application. It starts up all Chaplin core modules and starts the routing. It is loaded and instantiated in index.html. contains all application routes which map URLs to controller actions.


Since Chaplin is template-engine agnostic, you have to decide which templating solution you want to use and how you want to load the templates. This example uses Handlebars templates and loads them on-demand using the RequireJS Text plugin.

Chaplin expects that views implement the getTemplateFunction method which needs to return the actual templating function. Since all views in this example use the same templating solution, getTemplateFunction is provided once by two base classes all other views inherit from:

  • coffee/views/base/
  • coffee/views/base/

The actual .hbs template files are located in the js/templates directory.

Application-specific Extensions

To ease the development, this repository also provides application-specific base classes for models, collections and controllers. They inherit from the Chaplin base classes:

  • coffee/models/base/
  • coffee/models/base/
  • coffee/controllers/base/

Furthermore, coffee/lib/ and coffee/lib/ demonstrate how to extend the feature testing and utility files of Chaplin.

Last but not least, this example uses a specific Layout class which can be found in coffee/views/

The Cast

The Producers