Skip to content

Commit

Permalink
Fixes #13 - <async-fragment> to <await>
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-steele-idem committed Jun 30, 2016
1 parent 6b7f9a8 commit 0f996f0
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/transformers/async-fragment-error-tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

exports.transform = function(el) {
el.setTagName('await-error');
};
5 changes: 5 additions & 0 deletions src/transformers/async-fragment-placeholder-tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

exports.transform = function(el) {
el.setTagName('await-placeholder');
};
13 changes: 13 additions & 0 deletions src/transformers/async-fragment-tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

exports.transform = function(el) {

var dataProvider = el.getAttributeValue('data-provider');
var varName = el.getAttributeValue('var');

el.removeAttribute('data-provider');
el.removeAttribute('var');

el.argument = varName.value + ' from ' + dataProvider;
el.setTagName('await');
};
5 changes: 5 additions & 0 deletions src/transformers/async-fragment-timeout-tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

exports.transform = function(el) {
el.setTagName('await-timeout');
};
19 changes: 11 additions & 8 deletions test/fixtures/autotest/async-fragment/expected.marko
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<async-fragment data-provider=data.userProfileDataProvider var="userProfile"
arg-userId=data.userId>
<await(userProfile from data.userProfileDataProvider) arg-userId=data.userId>
<await-placeholder>
This is alternate content while the async fragment is loading.
</await-placeholder>
<await-timeout>A timeout has occurred!</await-timeout>
<await-error>A error has occurred!</await-error>
<ul>
<li>First name: ${userProfile.firstName}</li>
<li>Last name: ${userProfile.lastName}</li>
<li>Email address: ${userProfile.email}</li>
</ul>
</async-fragment>
</await>

~~~~~~~
async-fragment [
data-provider=data.userProfileDataProvider
var="userProfile"
arg-userId=data.userId
]
await(userProfile from data.userProfileDataProvider) arg-userId=data.userId
await-placeholder - This is alternate content while the async fragment is loading.
await-timeout - A timeout has occurred!
await-error - A error has occurred!
ul
li - First name: ${userProfile.firstName}
li - Last name: ${userProfile.lastName}
Expand Down
10 changes: 10 additions & 0 deletions test/fixtures/autotest/async-fragment/template.marko
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
var="userProfile"
arg-userId="${data.userId}">

<async-fragment-placeholder>
This is alternate content while the async fragment is loading.
</async-fragment-placeholder>
<async-fragment-timeout>
A timeout has occurred!
</async-fragment-timeout>
<async-fragment-error>
A error has occurred!
</async-fragment-error>

<ul>
<li>
First name: ${userProfile.firstName}
Expand Down

0 comments on commit 0f996f0

Please sign in to comment.