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

Tell templates where they're being rendered #26

Closed
arctic-hen7 opened this issue Sep 25, 2021 · 4 comments
Closed

Tell templates where they're being rendered #26

arctic-hen7 opened this issue Sep 25, 2021 · 4 comments
Assignees
Labels
A-templates Area: templates C-enhancement Category: enhancement D-easy Difficulty: easy good first issue Good for newcomers P-high Priority: high S-in-development Status: in development
Milestone

Comments

@arctic-hen7
Copy link
Member

Is your feature request related to a problem? Please describe.
Right now, web_sys panics if you call it on the server, and detecting if you're on the server with it is difficult and badly documented. Thus, it's very difficult to have client-side-only logic in Perseus, which is really a must for any framework like this.

Describe the solution you'd like
Perseus should provide a simple boolean argument to templates along with their state telling them if they're being rendered on the client or the server. This will make things orders of magnitude easier!

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@arctic-hen7 arctic-hen7 added C-enhancement Category: enhancement good first issue Good for newcomers A-templates Area: templates D-easy Difficulty: easy P-high Priority: high S-in-development Status: in development labels Sep 25, 2021
@arctic-hen7 arctic-hen7 self-assigned this Sep 25, 2021
@arctic-hen7
Copy link
Member Author

This will be released in v0.2.3.

@arctic-hen7
Copy link
Member Author

Also, this doesn't use a boolean parameter, but a context element, and provides a macro is_client! for checking easily in a reactive scope.

@arctic-hen7
Copy link
Member Author

Alright, my two solutions for this thus far have broken other parts of Perseus, so this is going to be a little harder than I thought!

@arctic-hen7 arctic-hen7 reopened this Sep 26, 2021
arctic-hen7 added a commit that referenced this issue Sep 26, 2021
This feature is tracked by #26, but will not be released in v0.2.3.
@arctic-hen7 arctic-hen7 added this to the v0.3.0 milestone Sep 28, 2021
@arctic-hen7
Copy link
Member Author

Okay, this will be released in v0.3.0 along with a refactoring of all errors to use thiserror instead of error_chain. If anyone figures out how to do this in just web_sys, please tell me! For now, it's done by explicitly passing in a boolean from the renderer (server says it's rendering on the server, client says it's hydrating on the client).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-templates Area: templates C-enhancement Category: enhancement D-easy Difficulty: easy good first issue Good for newcomers P-high Priority: high S-in-development Status: in development
Projects
None yet
Development

No branches or pull requests

1 participant