From cc8862994843b7e321e817d3fbffa8ddd422ec50 Mon Sep 17 00:00:00 2001 From: army8735 Date: Mon, 25 Aug 2014 16:38:14 +0800 Subject: [PATCH] save #12 --- src/Rest.js | 6 +++++- web/Rest.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Rest.js b/src/Rest.js index 31caa28..fe58f19 100644 --- a/src/Rest.js +++ b/src/Rest.js @@ -52,7 +52,7 @@ var Rest = Class(function(jsdc) { }; //主表达式中含有生成的对象,不是直接引用,需创建一个临时变量保存引用 if(needTemp) { - self.jsdc.append('var ' + temp + '='); + self.jsdc.append('function(){var ' + temp + '='); var first = node.first(); eventbus.on(first.nid(), function(node2, start) { if(!start) { @@ -113,6 +113,10 @@ var Rest = Class(function(jsdc) { this.jsdc.append('.concat('); this.jsdc.append(node.last().first().token().content()); this.jsdc.append(')'); + if(o.needTemp) { + //主表达式中含有生成的对象,不是直接引用,使用临时变量引用 + this.jsdc.append(';return ' + o.temp + '}'); + } } }, arrltr: function(node, start) { diff --git a/web/Rest.js b/web/Rest.js index 4e927d9..3ce6c9c 100644 --- a/web/Rest.js +++ b/web/Rest.js @@ -53,7 +53,7 @@ define(function(require, exports, module) { }; //主表达式中含有生成的对象,不是直接引用,需创建一个临时变量保存引用 if(needTemp) { - self.jsdc.append('var ' + temp + '='); + self.jsdc.append('function(){var ' + temp + '='); var first = node.first(); eventbus.on(first.nid(), function(node2, start) { if(!start) { @@ -114,6 +114,10 @@ define(function(require, exports, module) { this.jsdc.append('.concat('); this.jsdc.append(node.last().first().token().content()); this.jsdc.append(')'); + if(o.needTemp) { + //主表达式中含有生成的对象,不是直接引用,使用临时变量引用 + this.jsdc.append(';return ' + o.temp + '}'); + } } }, arrltr: function(node, start) {