-
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from shahedc/TagHelpers
Added experimental project to illustrate custom tag helpers
- Loading branch information
Showing
64 changed files
with
39,963 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace TagHelperAuthoring.Models | ||
{ | ||
public class SuperheroModel | ||
{ | ||
public string LastName { get; set; } | ||
public string FirstName { get; set; } | ||
public string SuperName { get; set; } | ||
public bool HasSurvived { get; set; } | ||
|
||
public bool ShowInfoWithSpoilers { get; set; } | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
experimental/TagHelperAuthoring/Pages/AsyncEmailTester.cshtml
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,23 @@ | ||
@page | ||
@using TagHelperAuthoring.TagHelpers; | ||
@{ | ||
ViewData["Title"] = "Async Email Tester"; | ||
} | ||
|
||
<h2>@ViewData["Title"]</h2> | ||
|
||
<address> | ||
Avengers HQ<br /> | ||
New York, NY 98052<br /> | ||
<abbr title="Phone">P:</abbr> | ||
718.555.0000 | ||
</address> | ||
|
||
<address> | ||
<strong>Black Widow:</strong> <async-email>Black.Widow</async-email><br /> | ||
<strong>Iron Man:</strong> <async-email>Iron.Man</async-email><br /> | ||
<strong>Thor:</strong> <async-email>Mighty.Thor</async-email><br /> | ||
<strong>Captain America:</strong> <async-email>Captain.America</async-email><br /> | ||
<strong>Hulk:</strong> <async-email>Incredible.Hulk</async-email><br /> | ||
<strong>Hawkeye:</strong> <async-email>Clint.Barton</async-email><br /> | ||
</address> |
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,11 @@ | ||
@page | ||
@using TagHelperAuthoring.TagHelpers; | ||
@{ | ||
ViewData["Title"] = "Bold Tester"; | ||
} | ||
|
||
<h2>@ViewData["Title"]</h2> | ||
|
||
<p bold>This paragraph uses a P tag with a bold attribute. Using a tag helper, the entire paragraph should be displayed with bold text.</p> | ||
|
||
<bold>This statement uses a custom bold tag to be displayed in bold.</bold> |
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,23 @@ | ||
@page | ||
@using TagHelperAuthoring.TagHelpers; | ||
@{ | ||
ViewData["Title"] = "Email Tester"; | ||
} | ||
|
||
<h2>@ViewData["Title"]</h2> | ||
|
||
<address> | ||
Avengers HQ<br /> | ||
New York, NY 98052<br /> | ||
<abbr title="Phone">P:</abbr> | ||
718.555.0000 | ||
</address> | ||
|
||
<address> | ||
<strong>Black Widow:</strong> <email mail-to="Black.Widow"></email><br /> | ||
<strong>Iron Man:</strong> <email mail-to="Iron.Man"></email><br /> | ||
<strong>Thor:</strong> <email mail-to="Mighty.Thor"></email><br /> | ||
<strong>Captain America:</strong> <email mail-to="Captain.America"></email><br /> | ||
<strong>Hulk:</strong> <email mail-to="Incredible.Hulk"></email><br /> | ||
<strong>Hawkeye:</strong> <email mail-to="Clint.Barton"></email><br /> | ||
</address> |
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 @@ | ||
@page | ||
@model ErrorModel | ||
@{ | ||
ViewData["Title"] = "Error"; | ||
} | ||
|
||
<h1 class="text-danger">Error.</h1> | ||
<h2 class="text-danger">An error occurred while processing your request.</h2> | ||
|
||
@if (Model.ShowRequestId) | ||
{ | ||
<p> | ||
<strong>Request ID:</strong> <code>@Model.RequestId</code> | ||
</p> | ||
} | ||
|
||
<h3>Development Mode</h3> | ||
<p> | ||
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred. | ||
</p> | ||
<p> | ||
<strong>The Development environment shouldn't be enabled for deployed applications.</strong> | ||
It can result in displaying sensitive information from exceptions to end users. | ||
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong> | ||
and restarting the app. | ||
</p> |
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,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace TagHelperAuthoring.Pages | ||
{ | ||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] | ||
public class ErrorModel : PageModel | ||
{ | ||
public string RequestId { get; set; } | ||
|
||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); | ||
|
||
private readonly ILogger<ErrorModel> _logger; | ||
|
||
public ErrorModel(ILogger<ErrorModel> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public void OnGet() | ||
{ | ||
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; | ||
} | ||
} | ||
} |
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,10 @@ | ||
@page | ||
@model IndexModel | ||
@{ | ||
ViewData["Title"] = "Home page"; | ||
} | ||
|
||
<div class="text-center"> | ||
<h1 class="display-4">Welcome</h1> | ||
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p> | ||
</div> |
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,25 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace TagHelperAuthoring.Pages | ||
{ | ||
public class IndexModel : PageModel | ||
{ | ||
private readonly ILogger<IndexModel> _logger; | ||
|
||
public IndexModel(ILogger<IndexModel> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public void OnGet() | ||
{ | ||
|
||
} | ||
} | ||
} |
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,8 @@ | ||
@page | ||
@model PrivacyModel | ||
@{ | ||
ViewData["Title"] = "Privacy Policy"; | ||
} | ||
<h1>@ViewData["Title"]</h1> | ||
|
||
<p>Use this page to detail your site's privacy policy.</p> |
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,24 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace TagHelperAuthoring.Pages | ||
{ | ||
public class PrivacyModel : PageModel | ||
{ | ||
private readonly ILogger<PrivacyModel> _logger; | ||
|
||
public PrivacyModel(ILogger<PrivacyModel> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public void OnGet() | ||
{ | ||
} | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
experimental/TagHelperAuthoring/Pages/Shared/_Layout.cshtml
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,63 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>@ViewData["Title"] - TagHelperAuthoring</title> | ||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" /> | ||
<link rel="stylesheet" href="~/css/site.css" /> | ||
</head> | ||
<body> | ||
<header> | ||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3"> | ||
<div class="container"> | ||
<a class="navbar-brand" asp-area="" asp-page="/Index">TagHelperAuthoring</a> | ||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent" | ||
aria-expanded="false" aria-label="Toggle navigation"> | ||
<span class="navbar-toggler-icon"></span> | ||
</button> | ||
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse"> | ||
<ul class="navbar-nav flex-grow-1"> | ||
<li class="nav-item"> | ||
<a class="nav-link text-dark" asp-area="" asp-page="/Index">Home</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link text-dark" asp-area="" asp-page="/Privacy">Privacy</a> | ||
</li> | ||
|
||
<li class="nav-item"> | ||
<a class="nav-link text-dark" asp-area="" asp-page="/EmailTester">Email Tester</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link text-dark" asp-area="" asp-page="/AsyncEmailTester">Async Email Tester</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link text-dark" asp-area="" asp-page="/BoldTester">Bold Tester</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link text-dark" asp-area="" asp-page="/SuperheroInfoTester">SuperheroInfoTester</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</nav> | ||
</header> | ||
<div class="container"> | ||
<main role="main" class="pb-3"> | ||
@RenderBody() | ||
</main> | ||
</div> | ||
|
||
<footer class="border-top footer text-muted"> | ||
<div class="container"> | ||
© 2020 - TagHelperAuthoring - <a asp-area="" asp-page="/Privacy">Privacy</a> | ||
</div> | ||
</footer> | ||
|
||
<script src="~/lib/jquery/dist/jquery.min.js"></script> | ||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script> | ||
<script src="~/js/site.js" asp-append-version="true"></script> | ||
|
||
@RenderSection("Scripts", required: false) | ||
</body> | ||
</html> |
2 changes: 2 additions & 0 deletions
2
experimental/TagHelperAuthoring/Pages/Shared/_ValidationScriptsPartial.cshtml
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 @@ | ||
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script> | ||
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script> |
28 changes: 28 additions & 0 deletions
28
experimental/TagHelperAuthoring/Pages/SuperheroInfoTester.cshtml
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 @@ | ||
@page | ||
@model SuperheroInfoTesterModel | ||
@using TagHelperAuthoring.TagHelpers; | ||
@using TagHelperAuthoring.Models; | ||
@{ | ||
ViewData["Title"] = "Superhero Info Tester"; | ||
|
||
} | ||
|
||
|
||
<h2>@ViewData["Title"]</h2> | ||
|
||
NOTE: Set ShowInfoWithSpoilers to true to display spoilers for each Endgame character. | ||
|
||
<h3>Black Widow Info:</h3> | ||
<div condition="@Model.blackWidowInfo.ShowInfoWithSpoilers"> | ||
<superhero hero-info="Model.blackWidowInfo" /> | ||
</div> | ||
|
||
<h3>Iron Man Info:</h3> | ||
<div condition="@Model.ironManInfo.ShowInfoWithSpoilers"> | ||
<superhero hero-info="Model.ironManInfo" /> | ||
</div> | ||
|
||
<h3>Thor Info:</h3> | ||
<div condition="@Model.thorInfo.ShowInfoWithSpoilers"> | ||
<superhero hero-info="Model.thorInfo" /> | ||
</div> |
48 changes: 48 additions & 0 deletions
48
experimental/TagHelperAuthoring/Pages/SuperheroInfoTester.cshtml.cs
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,48 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using TagHelperAuthoring.Models; | ||
|
||
namespace TagHelperAuthoring.Pages | ||
{ | ||
// WARNING: this class contains spoilers for Avengers Endgame (2019) | ||
public class SuperheroInfoTesterModel : PageModel | ||
{ | ||
public SuperheroModel blackWidowInfo { get; set; } | ||
public SuperheroModel ironManInfo { get; set; } | ||
public SuperheroModel thorInfo { get; set; } | ||
|
||
public void OnGet() | ||
{ | ||
blackWidowInfo = new SuperheroModel | ||
{ | ||
LastName = "Romanoff", | ||
FirstName = "Natasha", | ||
SuperName = "Black Widow", | ||
HasSurvived = false, | ||
ShowInfoWithSpoilers = true | ||
}; | ||
|
||
ironManInfo = new SuperheroModel | ||
{ | ||
LastName = "Stark", | ||
FirstName = "Tony", | ||
SuperName = "Iron Man", | ||
HasSurvived = false, | ||
ShowInfoWithSpoilers = true | ||
}; | ||
|
||
thorInfo = new SuperheroModel | ||
{ | ||
LastName = "Odinson", | ||
FirstName = "Thor", | ||
SuperName = "Mighty Thor", | ||
HasSurvived = true, | ||
ShowInfoWithSpoilers = true | ||
}; | ||
} | ||
} | ||
} |
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 @@ | ||
@using TagHelperAuthoring | ||
@namespace TagHelperAuthoring.Pages | ||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers | ||
@addTagHelper *, TagHelperAuthoring | ||
|
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 @@ | ||
@{ | ||
Layout = "_Layout"; | ||
} |
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.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace TagHelperAuthoring | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
CreateHostBuilder(args).Build().Run(); | ||
} | ||
|
||
public static IHostBuilder CreateHostBuilder(string[] args) => | ||
Host.CreateDefaultBuilder(args) | ||
.ConfigureWebHostDefaults(webBuilder => | ||
{ | ||
webBuilder.UseStartup<Startup>(); | ||
}); | ||
} | ||
} |
Oops, something went wrong.