node-barefoot
Version:
Barefoot makes code sharing between browser and server reality. Write your application once and run it on both ends of the wire.
56 lines (35 loc) • 8.71 kB
HTML
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Barefoot.Router - Barefoot</title><link rel="stylesheet" type="text/css" href="../../styles/main.css"><script language=JavaScript src="../../javascript/main.js"></script><script language=JavaScript src="../../javascript/prettify.js"></script><script language=JavaScript src="../../javascript/searchdata.js"></script></head><body class="ContentPage" onLoad="NDOnLoad();prettyPrint();"><script language=JavaScript><!--
if (browserType) {document.write("<div class=" + browserType + ">");if (browserVer) {document.write("<div class=" + browserVer + ">"); }}// --></script>
<!-- Generated by Natural Docs, version 1.52 -->
<!-- http://www.naturaldocs.org -->
<!-- saved from url=(0026)http://www.naturaldocs.org -->
<div id=Content><div class="CClass"><div class=CTopic id=MainTopic><h1 class=CTitle><a name="Barefoot.Router"></a>Barefoot.<wbr>Router</h1><div class=CBody><p>The barefoot router extends the default backbone router by applying environment specific mixins to it</p><p>For further information, please refer to the regarding environment specific mixins.</p><h4 class=CHeading>Environment Specific Mixins</h4><ul><li><a href="client/router-mixin-js.html#Barefoot.Router.Client" class=LMixin id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')">Barefoot.Router.Client</a></li><li><a href="server/router-mixin-js.html#Barefoot.Router.Server" class=LMixin id=link2 onMouseOver="ShowTip(event, 'tt2', 'link2')" onMouseOut="HideTip('tt2')">Barefoot.Router.Server</a></li></ul><h4 class=CHeading>Example Router Implementation</h4><blockquote><pre>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;
}
});</pre></blockquote><p>The following sections discuss specific aspects / differences of this code snippet in comparison to a common Backbone application.</p><h4 class=CHeading>Introduction of Barefoot.Router.render</h4><p>If you want barefoot to render a view for you, do <b>never</b> call the <a href="view-js.html#Barefoot.View" class=LClass id=link3 onMouseOver="ShowTip(event, 'tt3', 'link3')" onMouseOut="HideTip('tt3')">Barefoot.View</a> render function on yourself. Make sure you use the render function which is provided from <a href="#Barefoot.Router" class=LClass id=link4 onMouseOver="ShowTip(event, 'tt4', 'link4')" onMouseOut="HideTip('tt4')">Barefoot.Router</a> (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.</p><h4 class=CHeading>The Main View</h4><p>You have the option to define a “main view”. Understand this as a <a href="view-js.html#Barefoot.View" class=LClass id=link5 onMouseOver="ShowTip(event, 'tt3', 'link5')" onMouseOut="HideTip('tt3')">Barefoot.View</a> object which contains all common view objects like navigation bars, footer etc. If present in a <a href="#Barefoot.Router" class=LClass id=link6 onMouseOver="ShowTip(event, 'tt4', 'link6')" onMouseOut="HideTip('tt4')">Barefoot.Router</a>, this view gets automatically rendered before any other view.</p></div></div></div>
</div><!--Content-->
<div id=Footer>Generated on May 28th, 2013 · <a href="http://www.naturaldocs.org">Generated by Natural Docs</a></div><!--Footer-->
<div id=Menu><div class=MTitle>Barefoot</div><div class=MEntry><div class=MFile><a href="index-js.html">Barefoot</a></div></div><div class=MEntry><div class=MFile><a href="apiadapter-js.html">APIAdapter</a></div></div><div class=MEntry><div class=MFile><a href="cookieadapter-js.html">CookieAdapter</a></div></div><div class=MEntry><div class=MFile><a href="collection-js.html">Collection</a></div></div><div class=MEntry><div class=MFile><a href="datastore-js.html">DataStore</a></div></div><div class=MEntry><div class=MFile><a href="errors-js.html">Errors</a></div></div><div class=MEntry><div class=MFile><a href="model-js.html">Model</a></div></div><div class=MEntry><div class=MFile id=MSelected>Router</div></div><div class=MEntry><div class=MFile><a href="util-js.html">Util</a></div></div><div class=MEntry><div class=MFile><a href="view-js.html">View</a></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent1')">Client Mixins</a><div class=MGroupContent id=MGroupContent1><div class=MEntry><div class=MFile><a href="client/cookieadapter-mixin-js.html">CookieAdapter</a></div></div><div class=MEntry><div class=MFile><a href="client/datastore-mixin-js.html">DataStore</a></div></div><div class=MEntry><div class=MFile><a href="client/router-mixin-js.html">Router</a></div></div><div class=MEntry><div class=MFile><a href="client/start-js.html">Start</a></div></div><div class=MEntry><div class=MFile><a href="client/view-mixin-js.html">View</a></div></div></div></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent2')">Server Mixins</a><div class=MGroupContent id=MGroupContent2><div class=MEntry><div class=MFile><a href="server/apiadapter-mixin-js.html">APIAdapter</a></div></div><div class=MEntry><div class=MFile><a href="server/cookieadapter-mixin-js.html">CookieAdapter</a></div></div><div class=MEntry><div class=MFile><a href="server/datastore-mixin-js.html">DataStore</a></div></div><div class=MEntry><div class=MFile><a href="server/router-mixin-js.html">Router</a></div></div><div class=MEntry><div class=MFile><a href="server/start-js.html">Start</a></div></div><div class=MEntry><div class=MFile><a href="server/view-mixin-js.html">View</a></div></div></div></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent3')">Index</a><div class=MGroupContent id=MGroupContent3><div class=MEntry><div class=MIndex><a href="../../index/General.html">Everything</a></div></div><div class=MEntry><div class=MIndex><a href="../../index/Classes.html">Classes</a></div></div><div class=MEntry><div class=MIndex><a href="../../index/Errors.html">Errors</a></div></div><div class=MEntry><div class=MIndex><a href="../../index/Functions.html">Functions</a></div></div><div class=MEntry><div class=MIndex><a href="../../index/Mixins.html">Mixins</a></div></div><div class=MEntry><div class=MIndex><a href="../../index/PrivateFunctions.html">Private Functions</a></div></div></div></div></div><script type="text/javascript"><!--
var searchPanel = new SearchPanel("searchPanel", "HTML", "../../search");
--></script><div id=MSearchPanel class=MSearchPanelInactive><input type=text id=MSearchField value=Search onFocus="searchPanel.OnSearchFieldFocus(true)" onBlur="searchPanel.OnSearchFieldFocus(false)" onKeyUp="searchPanel.OnSearchFieldChange()"><select id=MSearchType onFocus="searchPanel.OnSearchTypeFocus(true)" onBlur="searchPanel.OnSearchTypeFocus(false)" onChange="searchPanel.OnSearchTypeChange()"><option id=MSearchEverything selected value="General">Everything</option><option value="Classes">Classes</option><option value="Errors">Errors</option><option value="Functions">Functions</option><option value="Mixins">Mixins</option><option value="PrivateFunctions">Private Functions</option></select></div><script language=JavaScript><!--
HideAllBut([1, 2], 4);// --></script></div><!--Menu-->
<!--START_ND_TOOLTIPS-->
<div class=CToolTip id="tt1"><div class=CMixin>Client specific code for the Barefoot.Router. </div></div><div class=CToolTip id="tt2"><div class=CMixin>This mixin contains any server side specific code for the Barefoot.Router.</div></div><div class=CToolTip id="tt3"><div class=CClass>The barefoot view extends the default backbone view by applying an environment specific mixin to it.</div></div><div class=CToolTip id="tt4"><div class=CClass>The barefoot router extends the default backbone router by applying environment specific mixins to it</div></div><!--END_ND_TOOLTIPS-->
<div id=MSearchResultsWindow><iframe src="" frameborder=0 name=MSearchResults id=MSearchResults></iframe><a href="javascript:searchPanel.CloseResultsWindow()" id=MSearchResultsWindowClose>Close</a></div>
<script language=JavaScript><!--
if (browserType) {if (browserVer) {document.write("</div>"); }document.write("</div>");}// --></script></body></html>