You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That's a good idea. Adding a CancellationToken property and a RenderAsync overload/default argument makes sense. I suppose I should also add this to Render for parity's sake.
In the meantime, you can work around the lack of this feature by adding the property to the template, or by creating an intermediate base class. It's a bit cumbersome though.
Hi!
It would be nice to have some sort of
CancellationToken
inside a template, that you can pass by callingRender()
orRenderAsync()
.The motivation is such that a template may invoke async methods that support cancellation, so it could be nice to propagate a token during rendering.
In MiniRazor, I just exposed a
CancellationToken
property:https://github.com/Tyrrrz/MiniRazor/blob/c83bf8b9d4ed1d07dc4a377b30b308f6cecc44e2/MiniRazor.Runtime/TemplateBase.cs#L27-L28
Which is set when calling
RenderAsync()
:https://github.com/Tyrrrz/MiniRazor/blob/c83bf8b9d4ed1d07dc4a377b30b308f6cecc44e2/MiniRazor.CodeGen/TemplateClassGenerator.cs#L95-L103
The text was updated successfully, but these errors were encountered: