Barefoot.Router

The barefoot router extends the default backbone router by applying environment specific mixins to it

For further information, please refer to the regarding environment specific mixins.

Environment Specific Mixins

Example Router Implementation

var ExampleRouter = Barefoot.Router.extend({
    routes: {
        '': 'home'
        , 'about': 'about'
    }
    , home: function home() {
        this.render(new HomeView());
    }
    , home: function home() {
        this.render(new HomeView());
    }
    , mainView: function() {
        if(_.isUndefined(this._mainView)) {
            this._mainView = new ChromeView();
        }
        return this._mainView;
    }
});

The following sections discuss specific aspects / differences of this code snippet in comparison to a common Backbone application.

Introduction of Barefoot.Router.render

If you want barefoot to render a view for you, do never call the Barefoot.View render function on yourself.  Make sure you use the render function which is provided from Barefoot.Router (In the example: “this.render(new HomeView());”).  This way ensures that the view is rendered properly on the server but also on the client side.

The Main View

You have the option to define a “main view”.  Understand this as a Barefoot.View object which contains all common view objects like navigation bars, footer etc.  If present in a Barefoot.Router, this view gets automatically rendered before any other view.

Client specific code for the Barefoot.Router.
This mixin contains any server side specific code for the Barefoot.Router.
The barefoot view extends the default backbone view by applying an environment specific mixin to it.
The barefoot router extends the default backbone router by applying environment specific mixins to it
Close