Can you use @Helper inside @Helper?

I am not sure if this is possible.

I have a bunch @Helperinside the view AND in other views:

@helper ViewHelper1()
{
   ...
}
@helper ViewHelper2()
{
   ...
}
etc.

I have repeating code that is used in an AND view in other views:

@if (!(Model.Entity == Model.Enum.One))
    {
        <td>
            @ViewHelper1()
        </td>
    }
    else
    { 
        <td>
            @ViewHelper1()
        </td>
        <td>
            @ViewHelper1()
        </td>
    }

Actual one @ViewHelper1has more complex code, but that doesn't matter (I think).

Well, since each view has a number @Helper(30+ views, 10-15 @Helpereach), and the structure <table>is the same, I was wondering how to make a creation @Helperin App_Codewhich encapsulates the structure <td>and then passes the view @Helper.

Say:

@helper Table(...) 
    {
        ...
    }

Or is it even possible, and then call it in a view, for example:

@Table(HelperView1)

If I need help with the syntax.

As always, much appreciated.

+3
1

- HelperResult. , HelperResult .

, :

@helper View1()
{
    <h1>View1</h1>
}

@helper View2()
{
    <h2>View2</h2>
}

@helper Table(Func<HelperResult> viewHelper)
{
    <text>Reuslt of viewHelper</text>
    @viewHelper()
}

@Table(View1)
@Table(View2)

:

Reuslt of viewHelper
<h1>View1</h1>

Reuslt of viewHelper
<h2>View2</h2>
+2

All Articles