Hello World!
This is my first blog post rendered dynamically from a .md file using ASP.NET Core and Markdig.
#### This is Markdown text inside of a Markdown block
* Item 1
* Item 2
### Dynamic Data is supported:
The current Time is: @DateTime.Now.ToString("HH:mm:ss")
// this c# is a code block
for (int i = 0; i < lines.Length; i++)
{
line1 = lines[i];
if (!string.IsNullOrEmpty(line1))
break;
}
You can also bind to Model values using the markdown attribute:
@model MarkdownModel
<markdown markdown="Model.MarkdownText" />
You can also easily parse Markdown both in code and inside of Razor Pages:
string html = Markdown.Parse(markdownText)
The content of the control is rendered to HTML at runtime which looks like this:
![]()
@@startuml
skinparam monochrome true
left to right direction
User1 --> (Story1)
(Story1) --> (Story2)
(Story2) --> (Story3)
@@enduml
What is a TagHelper?
TagHelpers are a new feature for ASP.NET Core MVC, and it's easily one of the nicest improvements for server side HTML generation. TagHelpers are self contained components that are embedded into a @Razor page. TagHelpers look like HTML tags and unlike Razor expressions (@Expression) feel natural inside of standard HTML content in a Razor page.
Many of the existing Model binding and HTML helpers in ASP.NET have been replaced by TagHelpers and TagHelper behaviors that allow you to directly bind to HTML controls in a page. For example, here is an Input tag bound to a model value.
For example:
<input type="email" asp-for="Email"
placeholder="Your email address"
class="form-control"/>
where asp-for extends the input element with an extension attribute to provide the model binding to the value property. This replaces:
@Html.TextBoxFor(model => model.Email,
new { @class = "form-control",
placeholder = "your email address",
type = "email" })
Which would you rather use? :-) TagHelpers make it easier to write your HTML markup by sticking to standard HTML syntax which feels more natural than using Razor expressions.
Bullet Lists
You can specify a filename to pull Markdown from and render into HTML. Files can be referenced:
- Milk
- Eggs
Number Bullet Lists
- First item
- Second item
- Third item