-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
95df053
commit d1a581f
Showing
14 changed files
with
148 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,38 @@ | ||
return (function (template, ctx) { | ||
let out = ""; | ||
ctx.$lineNumber = 1; | ||
ctx.$filename = "{{__dirname}}index.edge"; | ||
let $lineNumber = 1; | ||
let $filename = "{{__dirname}}index.edge"; | ||
try { | ||
ctx.set("total", 0, false); | ||
ctx.$lineNumber = 2; | ||
ctx.set("grossPrice", 0, false); | ||
ctx.$lineNumber = 3; | ||
ctx.loop(ctx.resolve('items'), function (item, loop) { | ||
ctx.newFrame(); | ||
ctx.setOnFrame('item', item); | ||
ctx.setOnFrame('$loop', loop); | ||
ctx.setOnFrame('key', loop.key); | ||
ctx.$lineNumber = 4; | ||
ctx.set("grossPrice", ctx.resolve('item').price * ctx.resolve('item').quantity, true); | ||
ctx.$lineNumber = 5; | ||
ctx.set("total", ctx.resolve('total') + ctx.resolve('grossPrice'), false); | ||
let total = 0; | ||
$lineNumber = 2; | ||
ctx.loop(state.items, function (item) { | ||
$lineNumber = 3; | ||
let grossPrice = item.price * item.quantity * state.surcharge; | ||
$lineNumber = 4; | ||
total = total + grossPrice; | ||
out += ""; | ||
out += "\n"; | ||
out += "- "; | ||
ctx.$lineNumber = 7; | ||
out += `${ctx.escape(ctx.resolve('item').name)}`; | ||
$lineNumber = 6; | ||
out += `${ctx.escape(item.name)}`; | ||
out += " x "; | ||
out += `${ctx.escape(ctx.resolve('item').quantity)}`; | ||
out += `${ctx.escape(item.quantity)}`; | ||
out += " = "; | ||
out += `${ctx.escape(ctx.resolve('grossPrice'))}`; | ||
ctx.removeFrame(); | ||
out += `${ctx.escape(grossPrice)}`; | ||
}); | ||
out += "\n"; | ||
out += "Total price = "; | ||
ctx.$lineNumber = 9; | ||
out += `${ctx.escape(ctx.resolve('total'))}`; | ||
$lineNumber = 8; | ||
out += `${ctx.escape(total)}`; | ||
out += "\n"; | ||
out += "Surcharge = "; | ||
$lineNumber = 9; | ||
out += `${ctx.escape(state.surcharge)}`; | ||
out += "\n"; | ||
out += "Gross price = "; | ||
ctx.$lineNumber = 10; | ||
out += `${ctx.escape(ctx.resolve('grossPrice'))}`; | ||
$lineNumber = 10; | ||
out += `${ctx.escape(state.grossPrice)}`; | ||
out += " "; | ||
} catch (error) { | ||
ctx.reThrow(error); | ||
ctx.reThrow(error, $filename, $lineNumber); | ||
} | ||
return out; | ||
})(template, ctx) | ||
return out; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
@set("total", 0) | ||
@set("grossPrice", 0) | ||
@each(item in items) | ||
@set("grossPrice", item.price * item.quantity, true) | ||
@set("grossPrice", (item.price * item.quantity) * surcharge) | ||
@set("total", total + grossPrice) | ||
|
||
- {{ item.name }} x {{ item.quantity }} = {{ grossPrice }} | ||
@endeach | ||
Total price = {{ total }} | ||
Gross price = {{ grossPrice }} | ||
Surcharge = {{ surcharge }} | ||
Gross price = {{ grossPrice }} {{-- Intentionally undefined --}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,6 @@ | |
"price": 2.99, | ||
"quantity": 4 | ||
} | ||
] | ||
], | ||
"surcharge": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
- Burger x 2 = 20 | ||
- Sandwich x 4 = 41.2 | ||
- Doughnut x 4 = 11.96 | ||
Total price = 73.16 | ||
Gross price = 0 | ||
- Burger x 2 = 40 | ||
- Sandwich x 4 = 82.4 | ||
- Doughnut x 4 = 23.92 | ||
Total price = 146.32 | ||
Surcharge = 2 | ||
Gross price = undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,15 @@ | ||
return (function (template, ctx) { | ||
let out = ""; | ||
ctx.$lineNumber = 1; | ||
ctx.$filename = "{{__dirname}}index.edge"; | ||
let $lineNumber = 1; | ||
let $filename = "{{__dirname}}index.edge"; | ||
try { | ||
ctx.loop([{ | ||
username: "virk" | ||
}], function (user, loop) { | ||
ctx.newFrame(); | ||
ctx.setOnFrame('user', user); | ||
ctx.setOnFrame('$loop', loop); | ||
ctx.setOnFrame('key', loop.key); | ||
}], function (user) { | ||
out += " - Hello "; | ||
ctx.$lineNumber = 2; | ||
out += `${ctx.escape(ctx.resolve('user').username)}`; | ||
ctx.removeFrame(); | ||
$lineNumber = 2; | ||
out += `${ctx.escape(user.username)}`; | ||
}); | ||
} catch (error) { | ||
ctx.reThrow(error); | ||
ctx.reThrow(error, $filename, $lineNumber); | ||
} | ||
return out; | ||
})(template, ctx) | ||
return out; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,18 @@ | ||
return (function (template, ctx) { | ||
let out = ""; | ||
ctx.$lineNumber = 1; | ||
ctx.$filename = "{{__dirname}}index.edge"; | ||
let $lineNumber = 1; | ||
let $filename = "{{__dirname}}index.edge"; | ||
try { | ||
if(ctx.size(ctx.resolve('users'))) { | ||
ctx.loop(ctx.resolve('users'), function (user, loop) { | ||
ctx.newFrame(); | ||
ctx.setOnFrame('user', user); | ||
ctx.setOnFrame('$loop', loop); | ||
ctx.setOnFrame('key', loop.key); | ||
if(ctx.size(state.users)) { | ||
ctx.loop(state.users, function (user) { | ||
out += " - Hello "; | ||
ctx.$lineNumber = 2; | ||
out += `${ctx.escape(ctx.resolve('user').username)}`; | ||
$lineNumber = 2; | ||
out += `${ctx.escape(user.username)}`; | ||
out += "\n"; | ||
ctx.removeFrame(); | ||
}); | ||
} else { | ||
out += " No users found"; | ||
} | ||
} catch (error) { | ||
ctx.reThrow(error); | ||
ctx.reThrow(error, $filename, $lineNumber); | ||
} | ||
return out; | ||
})(template, ctx) | ||
return out; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
let out = ""; | ||
let $lineNumber = 1; | ||
let $filename = "{{__dirname}}index.edge"; | ||
try { | ||
ctx.loop(state.users, function (user,index) { | ||
$lineNumber = 2; | ||
out += `${template.renderInline('each-tag-include/user', "user","index")(template, state, ctx, user,index)}`; | ||
}); | ||
} catch (error) { | ||
ctx.reThrow(error, $filename, $lineNumber); | ||
} | ||
return out; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@each((user, index) in users) | ||
@include('each-tag-include/user') | ||
@endeach |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"users": [{ | ||
"username": "virk" | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Hello virk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Hello {{ user.username }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,13 @@ | ||
return (function (template, ctx) { | ||
let out = ""; | ||
ctx.$lineNumber = 1; | ||
ctx.$filename = "{{__dirname}}index.edge"; | ||
let $lineNumber = 1; | ||
let $filename = "{{__dirname}}index.edge"; | ||
try { | ||
ctx.loop(ctx.resolve('users'), function (user, loop) { | ||
ctx.newFrame(); | ||
ctx.setOnFrame('user', user); | ||
ctx.setOnFrame('$loop', loop); | ||
ctx.setOnFrame('index', loop.key); | ||
ctx.loop(state.users, function (user,index) { | ||
out += " - Hello "; | ||
ctx.$lineNumber = 2; | ||
out += `${ctx.escape(ctx.resolve('user').username)}`; | ||
ctx.removeFrame(); | ||
$lineNumber = 2; | ||
out += `${ctx.escape(user.username)}`; | ||
}); | ||
} catch (error) { | ||
ctx.reThrow(error); | ||
ctx.reThrow(error, $filename, $lineNumber); | ||
} | ||
return out; | ||
})(template, ctx) | ||
return out; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,13 @@ | ||
return (function (template, ctx) { | ||
let out = ""; | ||
ctx.$lineNumber = 1; | ||
ctx.$filename = "{{__dirname}}index.edge"; | ||
let $lineNumber = 1; | ||
let $filename = "{{__dirname}}index.edge"; | ||
try { | ||
ctx.loop(ctx.resolve('users'), function (user, loop) { | ||
ctx.newFrame(); | ||
ctx.setOnFrame('user', user); | ||
ctx.setOnFrame('$loop', loop); | ||
ctx.setOnFrame('key', loop.key); | ||
ctx.loop(state.users, function (user) { | ||
out += " - Hello "; | ||
ctx.$lineNumber = 2; | ||
out += `${ctx.escape(ctx.resolve('user').username)}`; | ||
ctx.removeFrame(); | ||
$lineNumber = 2; | ||
out += `${ctx.escape(user.username)}`; | ||
}); | ||
} catch (error) { | ||
ctx.reThrow(error); | ||
ctx.reThrow(error, $filename, $lineNumber); | ||
} | ||
return out; | ||
})(template, ctx) | ||
return out; |
Oops, something went wrong.