-
Notifications
You must be signed in to change notification settings - Fork 25
/
Template.cs
32 lines (30 loc) · 844 Bytes
/
Template.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System.Collections.Generic;
using System.Net;
using System.Text;
namespace TodoMVC
{
public class Template
{
public string ItemList(List<Item> items)
{
StringBuilder sb = new StringBuilder();
foreach (var item in items)
{
sb.Append($@"
<li data-id=""{item.Id}""{(item.Completed!.Value ? " class=\"completed\"" : "")}>
<div class=""view"">
<input class=""toggle"" type=""checkbox"" {(item.Completed.Value ? "checked" : "")}>
<label>{WebUtility.HtmlEncode(item.Title ?? "")}</label>
<button class=""destroy""></button>
</div>
</li>
");
}
return sb.ToString();
}
public string itemCounter(int activeTodos)
{
return $"{activeTodos} item{(activeTodos != 1 ? "s" : "")} left";
}
}
}