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.
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.
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.
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.