-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tera: Attempt to obtain mutable reference. #190
Conversation
I'll take a look at this; I don't think we want to expose Arc::get_mut without a lot of large warnings because it will panic if the application is being run. If we need to expose mutable access to the inner Tera, it will need to be in an RwLock to ensure we don't panic |
Gotcha. And I can imagine something like that would change the internal representation a bit (perhaps to something like |
How are you triggering the reload? Is it a fs-watch driven thing? Do you think it might make sense to make "reload on each request" a development mode option? |
I'm aiming to make it a development option, yeah. Right now, I'm killing the process and restarting it. My other option is to have a connection catch the request, clone the Tera instance into a mutable one and reload it from there (which, tbh, feels like the more 'correct' option because this is in a conditional handler when it's determined to be in a development mode).
…On Sun, Mar 27, 2022, at 18:03, Jacob Rothstein wrote:
How are you triggering the reload? Is it a fs-watch driven thing? Do
you think it might make sense to make "reload on each request" a
development mode option?
--
Reply to this email directly or view it on GitHub:
#190 (comment)
You are receiving this because you authored the thread.
Message ID: ***@***.***>
|
Yeah, I've been just doing the following in my list of handlers, and it works well for me. I think I can just put this behind a feature flag in a separate function. The performance isn't really measurable yet (I only have about ten pages there):
I actually do something similar in the code running my personal site, only to allow for runtime swapping of themes. If I do notice anything performance-wise, I'll come back with a better PR for that. (Originally published at: https://jacky.wtf/2022/3/ZV/ZVqfcJwEH7Mo2g-hSTvCnXSb) |
I'm a few days backlogged on trillium, but I do think this is a general purpose utility that people might want, so I'll make an issue to represent this. One of the outstanding design issues that I haven't really addressed is whether there should be some explicit notion of "development mode," and I think there are good arguments on both sides of that issue |
That sounds good to me—in that case, I can probably spend some time this weekend looking into making this PR a bit more reasonable. In the case I had, just reloading the templates on disk would have been enough, so having a private flag that inform the handler to call I think doing this removes it from being a development-specific use case (which falls into the case of my personal site) but still allows it to be used in such a context (for this Webmention server app I'm making) . (Originally published at: https://jacky.wtf/2022/3/nR/nRJ9TgFL45dF2Swh4UhxXYL7) |
I've come into a situation where I need to call
Tera::full_reload
so I can reload templates in a development environment (versus respawning this application). I'm not sure if allowing for aFrom<Arc<Tera>> for TeraHandler
would have helped here (because then I can control the instance of Tera being used (to a degree).I know I opened this up as a PR versus going into discussions—mainly because it seemed simple enough. However, I can't get this imported into my project locally so I wasn't able to fully test this.