-
Notifications
You must be signed in to change notification settings - Fork 56
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
Implement Render trait for Option #84
base: main
Are you sure you want to change the base?
Conversation
✔️ Deploy Preview for rust-sailfish ready! 🔨 Explore the source changes: 7ce8cd9 🔍 Inspect the deploy log: https://app.netlify.com/sites/rust-sailfish/deploys/622c8bdf00f4120009bd3723 😎 Browse the preview: https://deploy-preview-84--rust-sailfish.netlify.app |
@jdrouet @Kogia-sima What do you think? |
I think it is an good Idea, however I would rather see something like a different syntax.
|
@godofdream Why the different syntax? Just curious. I like the current one because it reminds me of old ASP. |
@vthg2themax this would ommit the risk of accidentially render Options |
@godofdream I can understand that then. Perhaps the code committer may want to make the change possibly? |
Sorry for taking a while to respond! Dead markup is definitely a valid concern. But Sailfish isn't strictly a HTML templating library - it can be used to render any kind of text. If I recall correctly there used to be a crate on crates.io that used Sailfish to render a Debian package manifest or something along those lines. For non-HTML formats where "dead markup" isn't an issue, this could be an ergonomic addition. It is still possible to render dead markup, but I guess harder to do on accident: <span><%= if let Some(usr) = username { usr } %></span>
// when None, results in:
<span></span>
Is the idea that What about cases like this where you'd want the operator to remove both the <ul>
<li>
<span><%=~ an_option %></span>
</li>
</ul> |
@godofdream @Svenskunganka @Kogia-sima I have been thinking it would be cool if we had like a 'sailfish-web' option for our crate that would allow us to opt-in to implementing specific ergonomic changes to our project such as making it easier for developers to handle these option elements in a more web focused way that gives preference to developer productivity if they opt-in, but also still will allow things to proceed quickly, and safely. What do you guys think? |
Well I can implement features you'd like into sailfish-web, under some feature maybe called "convenience"? |
Given a template struct of this:
PR allows to do this:
instead of:
The drawback is that it's easier to accidentally render dead markup, e.g:
I also have an implementation for
Result<T, E>
whereT: Render
over in https://github.com/Svenskunganka/sailfish/tree/render_result but after some consideration I don't think that's a good idea - but please give your opinion as well! See also #52