asp.net mvc - Why can't one Razor helper call another helper? -
i'm running razor code below in .cshtml file (it's simplified version of more complex need achieve), rendertestb helper not seem execute.
@rendertesta("test string 1", "test string 2"); @helper rendertesta(string input1, string input2) { <div> @rendertestb(input1) @rendertestb(input2) </div> } @helper rendertestb(string input) { <p class="test">@input</p> } why this? , there way of achieving i'm trying do?
i realise duplicate paragraph code within rendertesta helper, prefer re-usable code solution.
what this?
@rendertesta(rendertestb("test string 1"), rendertestb("test string 2")) @helper rendertesta(string input1, string input2) { <div> @input1 @input2 </div> } @helper rendertestb(string input) { <p class="test">@input</p> } you should consider using editor / display templates or custom html helpers instead @helper functionality used before these features became norm.
as why cannot nest them. introduces number of problems avoided using syntax suggested above. such as... if have circular loop of nested helpers, cause stack overflow.
Comments
Post a Comment