-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
16 changed files
with
249 additions
and
15 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
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
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
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
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
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
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 @@ | ||
{{model System.String}} | ||
{{layout Main}} | ||
<h1>You said {{.}}</h1> |
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,26 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Text; | ||
using System.Collections.Generic; | ||
using AspDotNetCore.Views.Layouts; | ||
using CompiledHandlebars.RuntimeUtils; | ||
using static CompiledHandlebars.RuntimeUtils.RenderHelper; | ||
|
||
namespace AspDotNetCore.Views | ||
{ | ||
[CompiledHandlebarsTemplate] | ||
public static class Echo | ||
{ | ||
public static string Render(System.String viewModel) | ||
{ | ||
var sb = new StringBuilder(64); | ||
sb.Append(Main.PreRender(viewModel)); | ||
sb.Append("\r\n<h1>You said "); | ||
sb.Append(WebUtility.HtmlEncode(viewModel)); | ||
sb.Append("</h1>"); | ||
sb.Append(Main.PostRender(viewModel)); | ||
return sb.ToString(); | ||
} | ||
} | ||
} |
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,4 @@ | ||
{{model System.String}} | ||
{{layout Main}} | ||
<h1>Hello {{.}}</h1> | ||
{{> Footer "Partial"}} |
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,28 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Text; | ||
using System.Collections.Generic; | ||
using AspDotNetCore.Views.Layouts; | ||
using AspDotNetCore.Views.Partials; | ||
using CompiledHandlebars.RuntimeUtils; | ||
using static CompiledHandlebars.RuntimeUtils.RenderHelper; | ||
|
||
namespace AspDotNetCore.Views | ||
{ | ||
[CompiledHandlebarsTemplate] | ||
public static class Greet | ||
{ | ||
public static string Render(System.String viewModel) | ||
{ | ||
var sb = new StringBuilder(64); | ||
sb.Append(Main.PreRender(viewModel)); | ||
sb.Append("\r\n\t<h1>Hello "); | ||
sb.Append(WebUtility.HtmlEncode(viewModel)); | ||
sb.Append("</h1>\r\n"); | ||
sb.Append(Footer.Render("Partial")); | ||
sb.Append(Main.PostRender(viewModel)); | ||
return sb.ToString(); | ||
} | ||
} | ||
} |
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 @@ | ||
{{model System.String}} | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>{{.}}</title> | ||
</head> | ||
<body> | ||
{{body}} | ||
{{> Footer "Partial in the layout"}} | ||
</body> | ||
</html> |
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,64 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Text; | ||
using System.Collections.Generic; | ||
using AspDotNetCore.Views.Partials; | ||
|
||
namespace AspDotNetCore.Views.Layouts | ||
{ | ||
[CompiledHandlebarsLayout] | ||
public static class Main | ||
{ | ||
public static string PostRender(System.String viewModel) | ||
{ | ||
var sb = new StringBuilder(64); | ||
sb.Append("\r\n\t"); | ||
sb.Append(Footer.Render("Partial")); | ||
sb.Append("\r\n</body>\r\n</html>"); | ||
return sb.ToString(); | ||
} | ||
|
||
public static string PreRender(System.String viewModel) | ||
{ | ||
var sb = new StringBuilder(64); | ||
sb.Append("\r\n<!DOCTYPE html>\r\n<html>\r\n<head>\r\n <meta charset=\"utf-8\" />\r\n <title>"); | ||
sb.Append(WebUtility.HtmlEncode(viewModel)); | ||
sb.Append("</title>\r\n</head>\r\n<body>\r\n\t"); | ||
return sb.ToString(); | ||
} | ||
|
||
private static bool IsTruthy(bool b) | ||
{ | ||
return b; | ||
} | ||
|
||
private static bool IsTruthy(string s) | ||
{ | ||
return !string.IsNullOrEmpty(s); | ||
} | ||
|
||
private static bool IsTruthy(object o) | ||
{ | ||
return o != null; | ||
} | ||
|
||
private static bool IsTruthy<T>(IEnumerable<T> ie) | ||
{ | ||
return ie != null && ie.Any(); | ||
} | ||
|
||
private static bool IsTruthy(int i) | ||
{ | ||
return i != 0; | ||
} | ||
|
||
private class CompiledHandlebarsTemplateAttribute : Attribute | ||
{ | ||
} | ||
|
||
private class CompiledHandlebarsLayoutAttribute : Attribute | ||
{ | ||
} | ||
} | ||
} |
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,2 @@ | ||
{{model System.String}} | ||
<h2>This footer is embedded as {{.}}!</h2> |
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,54 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Text; | ||
using System.Collections.Generic; | ||
|
||
namespace AspDotNetCore.Views.Partials | ||
{ | ||
[CompiledHandlebarsTemplate] | ||
public static class Footer | ||
{ | ||
public static string Render(System.String viewModel) | ||
{ | ||
var sb = new StringBuilder(64); | ||
sb.Append("\r\n<h2>This footer is embedded as "); | ||
sb.Append(WebUtility.HtmlEncode(viewModel)); | ||
sb.Append("!</h2>"); | ||
return sb.ToString(); | ||
} | ||
|
||
private static bool IsTruthy(bool b) | ||
{ | ||
return b; | ||
} | ||
|
||
private static bool IsTruthy(string s) | ||
{ | ||
return !string.IsNullOrEmpty(s); | ||
} | ||
|
||
private static bool IsTruthy(object o) | ||
{ | ||
return o != null; | ||
} | ||
|
||
private static bool IsTruthy<T>(IEnumerable<T> ie) | ||
{ | ||
return ie != null && ie.Any(); | ||
} | ||
|
||
private static bool IsTruthy(int i) | ||
{ | ||
return i != 0; | ||
} | ||
|
||
private class CompiledHandlebarsTemplateAttribute : Attribute | ||
{ | ||
} | ||
|
||
private class CompiledHandlebarsLayoutAttribute : Attribute | ||
{ | ||
} | ||
} | ||
} |
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
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