Repository navigation
Closed
dotnet/arcade
#16884Description
I've implemented a fairly simple helper to handle if conditions.
For some reason, when i run the code first time, it ends up throwing an exception that this specific helper is not registered. If I hit the endpoint again, it works perfectly fine and continues to work fine until I restart the application, where it will then throw the exception again the first time.
Don't think it'll help, but cant hurt, the exception it throws:
HandlebarsDotNet.HandlebarsRuntimeException: Template references a helper that is not registered. Could not find helper 'ifCond'
at HandlebarsDotNet.Compiler.HelperFunctionBinder.LateBindHelperExpression(BindingContext context, String helperName, IEnumerable`1 arguments)
at lambda_method(Closure , TextWriter , Object )
at HandlebarsDotNet.Compiler.DeferredSectionVisitor.RenderSection(Object value, BindingContext context, Action`2 body, Action`2 inversion)
at lambda_method(Closure , TextWriter , Object )
at HandlebarsDotNet.Handlebars.HandlebarsEnvironment.<>c__DisplayClass7_0.<Compile>b__0(Object context)
at FileGeneratorService.Service.GeneratePDF(VM_Quote quote) in D:\Users\jola\Source\Repos\Utility Portal\FileGeneratorService\Service.cs:line 224
at WebAPI.Controllers.QuotesController.GetExport(Int32 id, String type) in D:\Users\jola\Source\Repos\Utility Portal\WebAPI\Controllers\QuotesController.cs:line 293
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at System.Threading.Tasks.ValueTask`1.get_Result()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext)
at WebAPI.MiddlewareDeveloperException.Invoke(HttpContext context) in D:\Users\jola\Source\Repos\Utility Portal\WebAPI\MiddlewareDeveloperException.cs:line 23
and the helper itself:
Handlebars.RegisterHelper("ifCond", (writer, options, context, arguments) =>
{
if (arguments[0] == null || arguments[1] == null)
{
options.Inverse(writer, (object)context);
return;
}
if (arguments[0].ToString() == arguments[1].ToString())
{
options.Template(writer, (object)context);
} else {
options.Inverse(writer, (object)context);
}
});
Metadata
Metadata
Assignees
Labels
No labels
Activity
rexm commentedon Dec 11, 2019
Can you please also share the template and the code where it is being compiled and invoked?
joamla96 commentedon Jan 7, 2020
A template where its being used looks like this:
and the invocation is set up like this:
Sorry for the late reply, it got drowned in my feed :D
artemutin commentedon May 7, 2020
I had kind of similar issue, and I was able to fix it by moving helper registration before compilation of any templates