Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently we are serving templates which are re-loadable
asynchronously. There are also assets which are shared by the
templates and are accessible through an async read lock.
For rendering we need to register specific helpers which will alter
the response for each request. The solution would be to clone all
templates for each request. Then add the specific helpers for that
situation. This is not ideal, because cloning all templates is slow.
So by adding an Arc to Templates, they can be shared between all
handlers building responses. Cloning is somewhat lighter with this
change. It does break the get_templates call on registry.
The other solution I have thought of was to add a generic type to the
render call, which can be used by the helpers. This can then default
to () for common cases.
Third solution would be to separate the template management from the
registry of helpers. In that case the templates can be put into a
custom structure, and would aid custom reloading schemes. E.g. loading
of the templates and then add that to a second structure holding the
helpers, then render. The registry is a composition of these two
structures.
Asynchronous helpers would also fix this for us. But in the mean time
this would help.