I am trying to return a formatted date from a razor template to umbraco. I am not sure how to get the value from the field defined in the parameter.
Here is the code I'm playing with. The field I am passing is called "articleDate". I get the output of the parameter value, however, when I try to get the field value using the parameter name, it does not return anything. If I ask for a value by the field name, this works. How to create a common macro like this?
@{var param = @Parameter.dateField;}
Field Name: @param
<br/>
Field Value: @Model.param
<br/>
Field Value: @Model.articleDate
I also tried using @ Model.GetDynamicMember (..), but that just throws an exception.
Field Value: @Model.GetDynamicMember("articleDate");
Error loading Razor Script getDate.cshtml
Cannot invoke a non-delegate type
Can someone point me in the right direction? I'm just trying to create a simple macro that I can use to format dates on my page.
? :
<umbraco:Macro ID="Macro1" Alias="getDate" dateField="articleDate" runat="server"></umbraco:Macro>