-
Notifications
You must be signed in to change notification settings - Fork 14
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
HxBoostedBy macro to avoid redundant if-else for layout #12
Comments
I'm okay with this. I think reducing the boilerplate is worth the additional complexity and I'm willing to maintain it long-term. It fits within the spirit of the library. Are you interested in starting a draft PR for this here? I imagine that most of your downstream work should be generally transferrable, though I haven't had a chance to look through your repo yet. |
That's great! Sure, I'll make a PR. |
Having used htmx + askama for a little while now the duplication and awkwardness of partial vs full pages is one of, if not the biggest pain point. Here's what it looks like for me: Constraints:
This ends in sadness. My workflow today looks as follows:
{% extends "../layouts/base.html" %}
{% block content %}
{% include "_index.html" %}
{% endblock %}
<h1>Register</h1>
<form hx-post="/register" hx-target="#container" hx-swap="innerHTML" hx-push-url="true">
<fieldset>
<div class="form-group">
<label for="email">Email</label>
<input class="form-control" name="email" />
</div>
<div class="form-group">
<label for="password">Password</label>
<input class="form-control" name="password" type="password" />
</div>
<input class="btn btn-primary" type="submit" />
</fieldset>
</form> These two are needed as the This is even before I have tackled including the user in the base template, which will make things even worse because the user only really needs to be loaded in the non-htmx case (as it doesn't change in the htmx case, typically). Also, every route would have to care about the user even though that kind of concern ideally should be dealt with "globally" by some middleware. Any ideas? |
Hi!
I'd like to propose a macros feature in addition to
HxBoosted
extractor.Currently with axum-htmx we use
HxBoosted
like this:I propose to add a macro, then it will be:
What this macro does is transforming that function to:
I don't have much experience with Rust but managed to write something close to that macro in this axum-htmx-derive repo. Didn't publish yet, don't think it requires separate package - but needs to be included in axum-htmx (with feature flag).
Currently it has 2 macros:
hx_boosted_by
andhx_boosted_by_async
- if you have any idea on how it can be merged I'm here :)Let me know what you think.
The text was updated successfully, but these errors were encountered: