Skip to content
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

RFC 1: Dynamic Template Loading #1

Open
Kogia-sima opened this issue Jun 5, 2020 · 2 comments
Open

RFC 1: Dynamic Template Loading #1

Kogia-sima opened this issue Jun 5, 2020 · 2 comments
Labels
Priority: Low Status: Proposal Request for comments Status: RFC Request for comments

Comments

@Kogia-sima
Copy link
Member

Kogia-sima commented Jun 5, 2020

Compile and load templates at runtime.

Rendered

@lingfei1999
Copy link

hi @Kogia-sima, is there any plan on progressing this proposal? It would be nice to have dynamic compiling at runtime.

@FlorianDevPhynix
Copy link

I've know spent a couple of months looking into using web assembly to solve this problem.
I had it working four months ago, just not as a macro. I now have finally figured out how this would work for sailfish.

My goal was to make it completely in-transparent when calling a render function.
Prototype

cfg attributes are used to switch between different implementations for host and guest.
When not compiling for wasm, the sailfish Template trait implementation calls a function in the web assembly vm.
This function is only compiled for wasm, because it uses a bindgen macro.
When compiling for wasm the sailfish Template trait is implemented normally.
The bind function then calls this render implementation. Then the render result is returned to the host.

The only problem with this is, that it will not work with generic struct Templates.
@Kogia-sima seems to have also not solved this problem with the "Dynamic template loading" rfc.
This means that any kind of layouting will be impossible, so Layouts can't be hot reloaded.
For me, loosing generics is a big issue. I can still finish this if there is interest, but I can't and won't use it myself. Sadly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Low Status: Proposal Request for comments Status: RFC Request for comments
Projects
None yet
Development

No branches or pull requests

3 participants