From c43f6c59aae3f5b6fcea666903b43afd5388acb8 Mon Sep 17 00:00:00 2001 From: ido Date: Mon, 10 Nov 2014 18:47:06 +0200 Subject: [PATCH] add function wrap --- src/reactTemplates.js | 2 +- test/data/div.js | 4 +++- test/data/test.js | 48 ++++++++++++++++++++++--------------------- 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/reactTemplates.js b/src/reactTemplates.js index e938bab..896bb31 100644 --- a/src/reactTemplates.js +++ b/src/reactTemplates.js @@ -15,7 +15,7 @@ var ifTemplate = _.template("((<%= condition %>)?(<%= body %>):null)"); var classSetTemplate = _.template("React.addons.classSet(<%= classSet %>)"); var tagTemplate = _.template("<%= name %>.apply(this,_.flatten([<%= props %>].concat([<%= children %>])))"); var commentTemplate = _.template(" /* <%= data %> */ "); -var templateTemplate = _.template("define([<%= requirePaths %>], function (<%= requireNames %>) {\n <%= injectedFunctions %>\nreturn <%= body %>\n});"); +var templateTemplate = _.template("define([<%= requirePaths %>], function (<%= requireNames %>) {\n <%= injectedFunctions %>\nreturn function(){ return <%= body %>};\n});"); var templateProp = "rt-repeat"; var ifProp = "rt-if"; diff --git a/test/data/div.js b/test/data/div.js index 16fd325..ddb946d 100644 --- a/test/data/div.js +++ b/test/data/div.js @@ -2,5 +2,7 @@ define([ 'react', 'lodash' ], function (React, _) { - return React.DOM.div.apply(this, _.flatten([{}].concat([]))); + return function () { + return React.DOM.div.apply(this, _.flatten([{}].concat([]))); + }; }); \ No newline at end of file diff --git a/test/data/test.js b/test/data/test.js index 3e34887..609cf33 100644 --- a/test/data/test.js +++ b/test/data/test.js @@ -2,32 +2,34 @@ define([ 'react', 'lodash' ], function (React, _) { - return React.DOM.div.apply(this, _.flatten([{}].concat([ - React.DOM.div.apply(this, _.flatten([{ - 'style': { - position: 'relative', - textAlign: 'center', - top: this.props.config.previewTop, - height: this.props.config.previewHeight - } - }].concat([React.DOM.div.apply(this, _.flatten([{ + return function () { + return React.DOM.div.apply(this, _.flatten([{}].concat([ + React.DOM.div.apply(this, _.flatten([{ 'style': { - margin: 'auto', - height: '100%', - width: this.props.config.previewWidth || '100%' + position: 'relative', + textAlign: 'center', + top: this.props.config.previewTop, + height: this.props.config.previewHeight } - }].concat([React.DOM.iframe.apply(this, _.flatten([{ - 'id': 'preview', - 'src': 'http://localhost/sites/412?ds=true', + }].concat([React.DOM.div.apply(this, _.flatten([{ 'style': { - width: '100%', + margin: 'auto', height: '100%', - border: '0' + width: this.props.config.previewWidth || '100%' } - }].concat([])))])))]))), - React.DOM.div.apply(this, _.flatten([{}].concat([ - 'editor', - !this.props.editorState.previewMode ? React.DOM.div.apply(this, _.flatten([{}].concat(['left bar']))) : null - ]))) - ]))); + }].concat([React.DOM.iframe.apply(this, _.flatten([{ + 'id': 'preview', + 'src': 'http://localhost/sites/412?ds=true', + 'style': { + width: '100%', + height: '100%', + border: '0' + } + }].concat([])))])))]))), + React.DOM.div.apply(this, _.flatten([{}].concat([ + 'editor', + !this.props.editorState.previewMode ? React.DOM.div.apply(this, _.flatten([{}].concat(['left bar']))) : null + ]))) + ]))); + }; }); \ No newline at end of file