@@ -17,28 +17,49 @@ module.exports = function(Handlebars, getTemplate) {
1717 }
1818 viewOptions = options . hash || { } ;
1919
20- // Pass through a reference to the app.
2120 var app = getProperty ( '_app' , this , options ) ;
21+ // Pass through a reference to the app.
2222 if ( app ) {
2323 viewOptions . app = app ;
2424 viewName = app . modelUtils . underscorize ( viewName ) ;
2525 } else {
2626 throw new Error ( "An App instance is required when rendering a view, it could not be extracted from the options." )
2727 }
2828
29- // Pass through a reference to the parent view.
30- var parentView = getProperty ( '_view' , this , options ) ;
31- if ( parentView ) {
32- viewOptions . parentView = parentView ;
29+ if ( isServer ) {
30+ // Pass through a reference to the parent view.
31+ var parentView = getProperty ( '_view' , this , options ) ;
32+ if ( parentView ) {
33+ viewOptions . parentView = parentView ;
34+ }
35+
36+ // get the Backbone.View based on viewName
37+ ViewClass = BaseView . getView ( viewName , app . options . entryPath ) ;
38+ view = new ViewClass ( viewOptions ) ;
39+
40+ // create the outerHTML using className, tagName
41+ html = view . getHtml ( ) ;
42+ return new Handlebars . SafeString ( html ) ;
3343 }
3444
35- // get the Backbone.View based on viewName
36- ViewClass = BaseView . getView ( viewName , app . options . entryPath ) ;
37- view = new ViewClass ( viewOptions ) ;
45+ // only create an element to pass attributes to a single point for view instantiation for client-side
3846
39- // create the outerHTML using className, tagName
40- html = view . getHtml ( ) ;
41- return new Handlebars . SafeString ( html ) ;
47+ // Builds a fetch_summary attribute
48+ viewOptions = BaseView . parseModelAndCollection ( app . modelUtils , viewOptions ) ;
49+ var fetchSummary = BaseView . extractFetchSummary ( app . modelUtils , viewOptions ) ;
50+ fetchSummary = JSON . stringify ( fetchSummary )
51+
52+ viewOptions [ 'fetch_summary' ] = fetchSummary
53+ viewOptions = _ . omit ( viewOptions , [ 'model' , 'collection' , 'app' ] )
54+
55+ // create a list of data attributes
56+ var attrString = _ . inject ( viewOptions , function ( memo , value , key ) {
57+ return memo += " data-" + key + "=\"" + _ . escape ( value ) + "\"" ;
58+ } , '' ) ;
59+
60+ return new Handlebars . SafeString (
61+ '<div data-render="true" ' + attrString + ' data-view="' + viewName + '"></div>'
62+ )
4263 } ,
4364
4465 partial : function ( templateName , options ) {
0 commit comments