From 283d26538e2107b471feef7e7da89a3806c9975b Mon Sep 17 00:00:00 2001 From: Lichun Zhan Date: Fri, 20 Dec 2013 10:08:08 -0800 Subject: [PATCH 1/5] issue #1306: update tests to verify the view path works for both ac.done and ac.partial.render --- .../frameworkapp/common/mojits/ACMojit/controller.common.js | 2 +- .../mojits/ACMojit/views/{ => testdir}/mytemplate1.mu.html | 0 .../common/mojits/PartialMojit/controller.common.js | 2 +- .../common/mojits/PartialMojit/views/{ => testdir}/sub.mu.html | 0 4 files changed, 2 insertions(+), 2 deletions(-) rename tests/func/applications/frameworkapp/common/mojits/ACMojit/views/{ => testdir}/mytemplate1.mu.html (100%) rename tests/func/applications/frameworkapp/common/mojits/PartialMojit/views/{ => testdir}/sub.mu.html (100%) diff --git a/tests/func/applications/frameworkapp/common/mojits/ACMojit/controller.common.js b/tests/func/applications/frameworkapp/common/mojits/ACMojit/controller.common.js index 339d40faa..eb4fde0a2 100644 --- a/tests/func/applications/frameworkapp/common/mojits/ACMojit/controller.common.js +++ b/tests/func/applications/frameworkapp/common/mojits/ACMojit/controller.common.js @@ -63,7 +63,7 @@ YUI.add('ActionContextMojit', function(Y, NAME) { }else if(test=="done9"){ ac.done({ foo: null }, {view: {name: "mytemplate1"}}); }else if(test=="done10"){ - ac.done({ foo: [ 1, 2, null, 4 ]}, {view: {name: "mytemplate1"}} ); + ac.done({ foo: [ 1, 2, null, 4 ]}, {view: {name: "testdir/mytemplate1"}} ); }else if(test=="flush8"){ ac.flush({data:"Hello, world!--from flush"}, {view: {name: "mytemplate"}}); ac.done(); diff --git a/tests/func/applications/frameworkapp/common/mojits/ACMojit/views/mytemplate1.mu.html b/tests/func/applications/frameworkapp/common/mojits/ACMojit/views/testdir/mytemplate1.mu.html similarity index 100% rename from tests/func/applications/frameworkapp/common/mojits/ACMojit/views/mytemplate1.mu.html rename to tests/func/applications/frameworkapp/common/mojits/ACMojit/views/testdir/mytemplate1.mu.html diff --git a/tests/func/applications/frameworkapp/common/mojits/PartialMojit/controller.common.js b/tests/func/applications/frameworkapp/common/mojits/PartialMojit/controller.common.js index 90a5acf1d..ddbace524 100644 --- a/tests/func/applications/frameworkapp/common/mojits/PartialMojit/controller.common.js +++ b/tests/func/applications/frameworkapp/common/mojits/PartialMojit/controller.common.js @@ -43,7 +43,7 @@ YUI.add('PartialMojit', function(Y, NAME) { ac.done(mymarkup); });*/ //ac.done(data); - ac.partial.render(data, "sub", function(error, mymarkup){ + ac.partial.render(data, "testdir/sub", function(error, mymarkup){ Y.log("HereController....."+mymarkup); ac.done(mymarkup); }) diff --git a/tests/func/applications/frameworkapp/common/mojits/PartialMojit/views/sub.mu.html b/tests/func/applications/frameworkapp/common/mojits/PartialMojit/views/testdir/sub.mu.html similarity index 100% rename from tests/func/applications/frameworkapp/common/mojits/PartialMojit/views/sub.mu.html rename to tests/func/applications/frameworkapp/common/mojits/PartialMojit/views/testdir/sub.mu.html From 23c3d097f2623de0fe0fc1d1efeb9de2e62f8ab6 Mon Sep 17 00:00:00 2001 From: Lichun Zhan Date: Thu, 16 Jan 2014 09:20:52 -0800 Subject: [PATCH 2/5] update test use the same template file --- .../frameworkapp/common/mojits/ACMojit/controller.common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/func/applications/frameworkapp/common/mojits/ACMojit/controller.common.js b/tests/func/applications/frameworkapp/common/mojits/ACMojit/controller.common.js index eb4fde0a2..98f302138 100644 --- a/tests/func/applications/frameworkapp/common/mojits/ACMojit/controller.common.js +++ b/tests/func/applications/frameworkapp/common/mojits/ACMojit/controller.common.js @@ -61,7 +61,7 @@ YUI.add('ActionContextMojit', function(Y, NAME) { }else if(test=="done8"){ ac.done({data:"Hello, world!--from done"}, {view: {name: "mytemplate"}}); }else if(test=="done9"){ - ac.done({ foo: null }, {view: {name: "mytemplate1"}}); + ac.done({ foo: null }, {view: {name: "testdir/mytemplate1"}}); }else if(test=="done10"){ ac.done({ foo: [ 1, 2, null, 4 ]}, {view: {name: "testdir/mytemplate1"}} ); }else if(test=="flush8"){ From e4fa6e22b95722792b22e6ccf8eab9075309cab4 Mon Sep 17 00:00:00 2001 From: Lichun Zhan Date: Thu, 16 Jan 2014 13:08:53 -0800 Subject: [PATCH 3/5] support views/partials/templatefile & passing instance instead of instance.type when partial.render calls renderer.render --- lib/app/addons/ac/partial.common.js | 2 +- lib/app/autoload/store.server.js | 8 ++++---- .../common/mojits/PartialMojit/controller.common.js | 2 +- .../common/mojits/PartialMojit/views/partials/sub.mu.html | 3 +++ .../common/mojits/PartialMojit/views/testdir/sub.mu.html | 3 --- tests/unit/lib/app/addons/ac/test-partial.common.js | 2 +- tests/unit/lib/app/autoload/test-store.server.js | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 tests/func/applications/frameworkapp/common/mojits/PartialMojit/views/partials/sub.mu.html delete mode 100644 tests/func/applications/frameworkapp/common/mojits/PartialMojit/views/testdir/sub.mu.html diff --git a/lib/app/addons/ac/partial.common.js b/lib/app/addons/ac/partial.common.js index 36c8aebb1..6fde404f2 100644 --- a/lib/app/addons/ac/partial.common.js +++ b/lib/app/addons/ac/partial.common.js @@ -63,7 +63,7 @@ YUI.add('mojito-partial-addon', function (Y, NAME) { id = NAME + '::' + (instance.id || '@' + instance.type) + '>render:' + view; - renderer.render(data, instance.type, mojitView, new Y.mojito.OutputBuffer(id, cb), meta); + renderer.render(data, instance, mojitView, new Y.mojito.OutputBuffer(id, cb), meta); }, /** diff --git a/lib/app/autoload/store.server.js b/lib/app/autoload/store.server.js index bf606dedd..12803262d 100644 --- a/lib/app/autoload/store.server.js +++ b/lib/app/autoload/store.server.js @@ -743,11 +743,11 @@ YUI.add('mojito-resource-store', function(Y, NAME) { if (res.name.indexOf('partials/') === 0) { // removing the "partials/" prefix details.partials[this._libs.path.basename(res.name)] = template; - } else { - details.views[res.name] = template; - details.views[res.name].assets = res.view.assets; - details.views[res.name].engine = res.view.engine; } + details.views[res.name] = template; + details.views[res.name].assets = res.view.assets; + details.views[res.name].engine = res.view.engine; + continue; } diff --git a/tests/func/applications/frameworkapp/common/mojits/PartialMojit/controller.common.js b/tests/func/applications/frameworkapp/common/mojits/PartialMojit/controller.common.js index ddbace524..8d8909ae2 100644 --- a/tests/func/applications/frameworkapp/common/mojits/PartialMojit/controller.common.js +++ b/tests/func/applications/frameworkapp/common/mojits/PartialMojit/controller.common.js @@ -43,7 +43,7 @@ YUI.add('PartialMojit', function(Y, NAME) { ac.done(mymarkup); });*/ //ac.done(data); - ac.partial.render(data, "testdir/sub", function(error, mymarkup){ + ac.partial.render(data, "partials/sub", function(error, mymarkup){ Y.log("HereController....."+mymarkup); ac.done(mymarkup); }) diff --git a/tests/func/applications/frameworkapp/common/mojits/PartialMojit/views/partials/sub.mu.html b/tests/func/applications/frameworkapp/common/mojits/PartialMojit/views/partials/sub.mu.html new file mode 100644 index 000000000..42efc196a --- /dev/null +++ b/tests/func/applications/frameworkapp/common/mojits/PartialMojit/views/partials/sub.mu.html @@ -0,0 +1,3 @@ +
+ +
\ No newline at end of file diff --git a/tests/func/applications/frameworkapp/common/mojits/PartialMojit/views/testdir/sub.mu.html b/tests/func/applications/frameworkapp/common/mojits/PartialMojit/views/testdir/sub.mu.html deleted file mode 100644 index 35a13dde5..000000000 --- a/tests/func/applications/frameworkapp/common/mojits/PartialMojit/views/testdir/sub.mu.html +++ /dev/null @@ -1,3 +0,0 @@ -
- -
\ No newline at end of file diff --git a/tests/unit/lib/app/addons/ac/test-partial.common.js b/tests/unit/lib/app/addons/ac/test-partial.common.js index 3b606fb8b..001b99f76 100644 --- a/tests/unit/lib/app/addons/ac/test-partial.common.js +++ b/tests/unit/lib/app/addons/ac/test-partial.common.js @@ -70,7 +70,7 @@ YUI().use('mojito-partial-addon', 'test', function (Y) { var mockRenderer = Mock(); Mock.expect(mockRenderer, { method: 'render', - args: [data, 'myInstanceType', Mock.Value.Object, Mock.Value.Object, Mock.Value.Object], + args: [data, command.instance, Mock.Value.Object, Mock.Value.Object, Mock.Value.Object], run: function (data, type, mojitView, adapter) { Assert.areEqual('myContentPath', mojitView['content-path']); adapter.done('renderdone'); diff --git a/tests/unit/lib/app/autoload/test-store.server.js b/tests/unit/lib/app/autoload/test-store.server.js index 26d9414fe..9727f8a00 100644 --- a/tests/unit/lib/app/autoload/test-store.server.js +++ b/tests/unit/lib/app/autoload/test-store.server.js @@ -149,7 +149,7 @@ YUI().use( 'server mojit instance views and binders': function() { var instance = {type:'test_mojit_1'}; store.expandInstanceForEnv('client', instance, {}, function(err, instance) { - A.areSame(3, Y.Object.keys(instance.views).length); + A.areSame(4, Y.Object.keys(instance.views).length); A.isObject(instance.views['test_1']); A.areSame('/static/test_mojit_1/views/test_1.hb.html', instance.views['test_1']['content-path']); From f181a7662bd209de7532113a4bb73db9b9b9a81c Mon Sep 17 00:00:00 2001 From: Lichun Zhan Date: Thu, 16 Jan 2014 13:12:35 -0800 Subject: [PATCH 4/5] add newline at end of file --- .../common/mojits/PartialMojit/views/partials/sub.mu.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/func/applications/frameworkapp/common/mojits/PartialMojit/views/partials/sub.mu.html b/tests/func/applications/frameworkapp/common/mojits/PartialMojit/views/partials/sub.mu.html index 42efc196a..6002d96a9 100644 --- a/tests/func/applications/frameworkapp/common/mojits/PartialMojit/views/partials/sub.mu.html +++ b/tests/func/applications/frameworkapp/common/mojits/PartialMojit/views/partials/sub.mu.html @@ -1,3 +1,3 @@
-
\ No newline at end of file + From 9693614a385d09a5ec230b502efb0798e8cfe66b Mon Sep 17 00:00:00 2001 From: Lichun Zhan Date: Fri, 24 Jan 2014 10:10:27 -0800 Subject: [PATCH 5/5] Update HISTORY.md with the fixes --- HISTORY.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index b686da548..177df332e 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -13,11 +13,18 @@ Features Bug Fixes --------- -* Issue #1280: Composite.execute cannot be called multiple times in the same mojit +* Issue #1306: ac.partial.render() throws error for handlebar custom helper Acknowledgements ---------------- +version 0.8.2 +================= + +Bug Fixes +--------- + +* Issue #1280: Composite.execute cannot be called multiple times in the same mojit version 0.8.1 =================