Razorlight: "The helper directive is not supported."

Created on 4 Jul 2017  路  4Comments  路  Source: toddams/RazorLight

I have @helper abc() {} in my template. When I parse my template with RazorLight, I got this message:

"The helper directive is not supported."

Most helpful comment

bumped into this today. I found this workaround:

@{
Func<int, int, IHtmlContent> PrintNumbers = (actual, assumed) =>
    new Func<object, IHtmlContent>(@<text>
            @((actual + assumed).EmptyIfZero())
            @if (assumed > 0)
            {
            <span class="--assumed">(@assumed found)</span>
            }
    </text>)(null);
}

and then use it as in good old times:

<td>@PrintNumbers(12,4)</td>

All 4 comments

Yes, it's not supported and there is no plan to support it in the nearest future

@toddams Is there any way to work around that? I'm happy to help if a PR is needed

bumped into this today. I found this workaround:

@{
Func<int, int, IHtmlContent> PrintNumbers = (actual, assumed) =>
    new Func<object, IHtmlContent>(@<text>
            @((actual + assumed).EmptyIfZero())
            @if (assumed > 0)
            {
            <span class="--assumed">(@assumed found)</span>
            }
    </text>)(null);
}

and then use it as in good old times:

<td>@PrintNumbers(12,4)</td>

@avs099 Thanks. Perhaps we should add this the FAQ.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kspearrin picture kspearrin  路  8Comments

TheColonel2688 picture TheColonel2688  路  6Comments

tresoldigiorgio picture tresoldigiorgio  路  4Comments

Hubert-Rybak picture Hubert-Rybak  路  5Comments

Rizzen picture Rizzen  路  4Comments