I'm trying to use display templates to change how a DateTime
is rendered but the default template is always being used.
The model:
public class ProgressDetailViewModel : MemberDetailBaseViewModel
{
// <snip>
public DateTime? CurrentJourneyStartDate { get; set; }
}
Display template:
@using DateTime.Extensions;
@model Nullable<System.DateTime>
@if (Model.HasValue)
{
<span class="form-control">@Model.Value.ToSpecificTimeZone().ToString()</span>
}
<span>Hello from display template</span>
The view:
@Html.DisplayFor(m => m.CurrentJourneyStartDate)
@Html.DisplayFor(m => m.CurrentJourneyStartDate, "DateTime")
The display templates seem to be in the correct location:
However the date is always rendered using the default template. I have downloaded the sample from the above link and this works fine when I edit it to include a DateTime
display template.
Environment:
- .NET 6
- ASP.NET Core MVC
- Runs in Docker on Alpine linux
Why aren't the display templates being picked up?