I have created a template using Razor Generator . now I need in a recursive function to create a nested list of items . I tried this solution but then all my codes became marked as errors .
@* Generator: Template *@
@functions
{
public IList<Models.Category> Topics
{
get;
set;
}
}
@helper ShowTree(IList<Models.Category> topics)
{
<ul>
@foreach (var topic in topics)
{
<li>
@topic.Title
@if (topic.Childs.Count > 0)
{
@{
ShowTree(topic.Childs);
}
}
</li>
}
</ul>
}
some of irrelevant errors I got after adding the helper :
-Error 3 Invalid expression term ';'
Error 4 Feature 'lambda expression' cannot be used because it is not part of the ISO-2 C# language specification
Error 13 Feature 'implicitly typed local variable' cannot be used because it is not part of the System C# language specification
Error 6 The name 'WriteLiteralTo' does not exist in the current context
but as I remove the helper method , all these just disappear !
did I do something wrong or creating helpers in Razor Templates is not possible ?