Skip to content

Commit

Permalink
refactor: finalize @component tag
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Mar 26, 2020
1 parent b082e67 commit 02abb68
Show file tree
Hide file tree
Showing 23 changed files with 146 additions and 205 deletions.
10 changes: 4 additions & 6 deletions fixtures/components-isolated-state/compiled.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
return (function (template, ctx) {
let out = "";
ctx.$lineNumber = 1;
ctx.$filename = "{{__dirname}}index.edge";
let $lineNumber = 1;
let $filename = "{{__dirname}}index.edge";
try {
out += template.renderWithState("components-isolated-state/alert", {}, { main: function () { return "" } });
} catch (error) {
ctx.reThrow(error);
ctx.reThrow(error, $filename, $lineNumber);
}
return out;
})(template, ctx)
return out;
22 changes: 10 additions & 12 deletions fixtures/components-named-slots/compiled.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
return (function (template, ctx) {
let out = "";
ctx.$lineNumber = 1;
ctx.$filename = "{{__dirname}}index.edge";
let $lineNumber = 1;
let $filename = "{{__dirname}}index.edge";
try {
out += template.renderWithState("components-named-slots/alert", {}, { main: function () {
let slot_main = "";
try {
slot_main += " Hello ";
ctx.$lineNumber = 2;
slot_main += `${ctx.escape(ctx.resolve('name'))}`;
$lineNumber = 2;
slot_main += `${ctx.escape(state.name)}`;
slot_main += " line 1";
slot_main += "\n";
slot_main += "\n";
slot_main += " Hello ";
ctx.$lineNumber = 6;
slot_main += `${ctx.escape(ctx.resolve('name'))}`;
$lineNumber = 6;
slot_main += `${ctx.escape(state.name)}`;
slot_main += " line 2";
} catch (error) {
ctx.reThrow(error);
ctx.reThrow(error, $filename, $lineNumber);
}
return slot_main;
}, "heading": function () {
let slot_4 = "";
try {
slot_4 += " This is title";
} catch (error) {
ctx.reThrow(error);
ctx.reThrow(error, $filename, $lineNumber);
}
return slot_4;
} });
} catch (error) {
ctx.reThrow(error);
ctx.reThrow(error, $filename, $lineNumber);
}
return out;
})(template, ctx)
return out;
16 changes: 7 additions & 9 deletions fixtures/components-partials/compiled.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
return (function (template, ctx) {
let out = "";
ctx.$lineNumber = 1;
ctx.$filename = "{{__dirname}}index.edge";
let $lineNumber = 1;
let $filename = "{{__dirname}}index.edge";
try {
out += template.renderWithState("components-partials/alert", { username: "virk" }, { main: function () {
let slot_main = "";
try {
slot_main += " Hello ";
ctx.$lineNumber = 2;
slot_main += `${ctx.escape(ctx.resolve('username') || "Guest")}`;
$lineNumber = 2;
slot_main += `${ctx.escape(state.username || "Guest")}`;
} catch (error) {
ctx.reThrow(error);
ctx.reThrow(error, $filename, $lineNumber);
}
return slot_main;
} });
} catch (error) {
ctx.reThrow(error);
ctx.reThrow(error, $filename, $lineNumber);
}
return out;
})(template, ctx)
return out;
12 changes: 5 additions & 7 deletions fixtures/components-props/compiled.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
return (function (template, ctx) {
let out = "";
ctx.$lineNumber = 1;
ctx.$filename = "{{__dirname}}index.edge";
let $lineNumber = 1;
let $filename = "{{__dirname}}index.edge";
try {
out += template.renderWithState("components-props/alert", { "title": "H1" }, { main: function () {
let slot_main = "";
try {
slot_main += "Hello world";
} catch (error) {
ctx.reThrow(error);
ctx.reThrow(error, $filename, $lineNumber);
}
return slot_main;
} });
} catch (error) {
ctx.reThrow(error);
ctx.reThrow(error, $filename, $lineNumber);
}
return out;
})(template, ctx)
return out;
23 changes: 9 additions & 14 deletions fixtures/components-slot-props/compiled.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
return (function (template, ctx) {
let out = "";
ctx.$lineNumber = 1;
ctx.$filename = "{{__dirname}}index.edge";
let $lineNumber = 1;
let $filename = "{{__dirname}}index.edge";
try {
out += template.renderWithState("components-slot-props/alert", {}, { main: function () { return "" }, "title": function (user) {
let slot_0 = "";
try {
ctx.newFrame();
ctx.setOnFrame('user', user);
slot_0 += " Hello ";
ctx.$lineNumber = 3;
slot_0 += `${ctx.escape(ctx.resolve('user').username)}`;
$lineNumber = 3;
slot_0 += `${ctx.escape(user.username)}`;
slot_0 += "\n";
slot_0 += " Hi ";
ctx.$lineNumber = 4;
slot_0 += `${ctx.escape(ctx.resolve('username'))}`;
ctx.removeFrame();
$lineNumber = 4;
slot_0 += `${ctx.escape(state.username)}`;
} catch (error) {
ctx.reThrow(error);
ctx.reThrow(error, $filename, $lineNumber);
}
return slot_0;
} });
} catch (error) {
ctx.reThrow(error);
ctx.reThrow(error, $filename, $lineNumber);
}
return out;
})(template, ctx)
return out;
16 changes: 7 additions & 9 deletions fixtures/components-slots-partials/compiled.js
Original file line number Diff line number Diff line change
@@ -1,20 +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 {
out += template.renderWithState("components-slots-partials/alert", {}, { main: function () {
let slot_main = "";
try {
ctx.$lineNumber = 2;
slot_main += `${template.renderInline("components-slots-partials/partial")(template, ctx)}`;
$lineNumber = 2;
slot_main += `${template.renderInline("components-slots-partials/partial")(template,state,ctx)}`;
} catch (error) {
ctx.reThrow(error);
ctx.reThrow(error, $filename, $lineNumber);
}
return slot_main;
} });
} catch (error) {
ctx.reThrow(error);
ctx.reThrow(error, $filename, $lineNumber);
}
return out;
})(template, ctx)
return out;
16 changes: 7 additions & 9 deletions fixtures/components-state/compiled.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
return (function (template, ctx) {
let out = "";
ctx.$lineNumber = 1;
ctx.$filename = "{{__dirname}}index.edge";
let $lineNumber = 1;
let $filename = "{{__dirname}}index.edge";
try {
out += template.renderWithState("components-state/alert", {}, { main: function () {
let slot_main = "";
try {
slot_main += " Hello ";
ctx.$lineNumber = 2;
slot_main += `${ctx.escape(ctx.resolve('username'))}`;
$lineNumber = 2;
slot_main += `${ctx.escape(state.username)}`;
} catch (error) {
ctx.reThrow(error);
ctx.reThrow(error, $filename, $lineNumber);
}
return slot_main;
} });
} catch (error) {
ctx.reThrow(error);
ctx.reThrow(error, $filename, $lineNumber);
}
return out;
})(template, ctx)
return out;
12 changes: 5 additions & 7 deletions fixtures/components/compiled.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
return (function (template, ctx) {
let out = "";
ctx.$lineNumber = 1;
ctx.$filename = "{{__dirname}}index.edge";
let $lineNumber = 1;
let $filename = "{{__dirname}}index.edge";
try {
out += template.renderWithState("components/alert", {}, { main: function () {
let slot_main = "";
try {
slot_main += " Hello world";
} catch (error) {
ctx.reThrow(error);
ctx.reThrow(error, $filename, $lineNumber);
}
return slot_main;
} });
} catch (error) {
ctx.reThrow(error);
ctx.reThrow(error, $filename, $lineNumber);
}
return out;
})(template, ctx)
return out;
10 changes: 4 additions & 6 deletions fixtures/debugger/compiled.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
return (function (template, ctx) {
let out = "";
ctx.$lineNumber = 1;
ctx.$filename = "{{__dirname}}index.edge";
let $lineNumber = 1;
let $filename = "{{__dirname}}index.edge";
try {
debugger;
out += "";
out += "\n";
out += "Hello";
} catch (error) {
ctx.reThrow(error);
ctx.reThrow(error, $filename, $lineNumber);
}
return out;
})(template, ctx)
return out;
2 changes: 1 addition & 1 deletion fixtures/each-tag-include/compiled.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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)}`;
out += `${template.renderInline('each-tag-include/user',"user","index")(template,state,ctx,user,index)}`;
});
} catch (error) {
ctx.reThrow(error, $filename, $lineNumber);
Expand Down
20 changes: 9 additions & 11 deletions fixtures/else-if-tag/compiled.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
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.resolve('username') === "virk") {
if (state.username === "virk") {
out += " Hello VK";
out += "\n";
ctx.$lineNumber = 3;
} else if (ctx.resolve('username')) {
$lineNumber = 3;
} else if (state.username) {
out += " Hello ";
ctx.$lineNumber = 4;
out += `${ctx.escape(ctx.resolve('username'))}`;
$lineNumber = 4;
out += `${ctx.escape(state.username)}`;
out += "\n";
} else {
out += " Hello Guest!";
}
} catch (error) {
ctx.reThrow(error);
ctx.reThrow(error, $filename, $lineNumber);
}
return out;
})(template, ctx)
return out;
16 changes: 7 additions & 9 deletions fixtures/else-tag/compiled.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
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.resolve('username')) {
if (state.username) {
out += " Hello ";
ctx.$lineNumber = 2;
out += `${ctx.escape(ctx.resolve('username'))}`;
$lineNumber = 2;
out += `${ctx.escape(state.username)}`;
out += "\n";
} else {
out += " Hello guest!";
}
} catch (error) {
ctx.reThrow(error);
ctx.reThrow(error, $filename, $lineNumber);
}
return out;
})(template, ctx)
return out;
16 changes: 7 additions & 9 deletions fixtures/if-tag/compiled.js
Original file line number Diff line number Diff line change
@@ -1,15 +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 {
if (ctx.resolve('username')) {
if (state.username) {
out += " Hello ";
ctx.$lineNumber = 2;
out += `${ctx.escape(ctx.resolve('username'))}`;
$lineNumber = 2;
out += `${ctx.escape(state.username)}`;
}
} catch (error) {
ctx.reThrow(error);
ctx.reThrow(error, $filename, $lineNumber);
}
return out;
})(template, ctx)
return out;
Loading

0 comments on commit 02abb68

Please sign in to comment.