Skip to content

Commit

Permalink
Compile readmes
Browse files Browse the repository at this point in the history
  • Loading branch information
davegaeddert committed Jun 21, 2024
1 parent 2ab5f31 commit f96e11f
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions bolt-htmx/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!-- This file is compiled from bolt-htmx/bolt/htmx/README.md. Do not edit this file directly. -->

# bolt-htmx
# HTMX

Integrate HTMX with templates and views.

The `bolt-htmx` Django package adds a couple of unique features for working with HTMX.
The `bolt-htmx` package adds a couple of unique features for working with HTMX.
One is [template fragments](#template-fragments) and the other is [view actions](#view-actions).

The combination of these features lets you build HTMX-powered views that focus on server-side rendering and avoid overly complicated URL structures or REST APIs that you may not otherwise need.
Expand Down Expand Up @@ -43,14 +43,6 @@ you can use the `{% htmx_js %}` template tag:

## Installation

You can install `bolt-htmx` with any Django project:

```sh
pip install bolt-htmx
```

Then add `bolt.htmx` to `settings.py`:

```python
INSTALLED_PACKAGES = [
# ...
Expand Down Expand Up @@ -142,7 +134,7 @@ a standard `div` is output that looks like this:
The `bolt-hx-fragment` is a custom attribute that we've added ("F" is for "Forge"),
but the rest are standard HTMX attributes.

When Django renders the response to an HTMX request,
When Bolt renders the response to an HTMX request,
it will get the `Bolt-HX-Fragment` header,
find the fragment with that name in the template,
and render that for the response.
Expand Down Expand Up @@ -211,7 +203,7 @@ class PullRequestDetailView(HTMXViewMixin, DetailView):

# Action handling methods follow this format:
# htmx_{method}_{action}
def htmx_post_open(self, request, *args, **kwargs):
def htmx_post_open(self):
self.object = self.get_object()

if self.object.state != "closed":
Expand All @@ -225,7 +217,7 @@ class PullRequestDetailView(HTMXViewMixin, DetailView):
context = self.get_context(object=self.object)
return self.render_to_response(context)

def htmx_post_close(self, request, *args, **kwargs):
def htmx_post_close(self):
self.object = self.get_object()

if self.object.state != "open":
Expand All @@ -237,7 +229,7 @@ class PullRequestDetailView(HTMXViewMixin, DetailView):
context = self.get_context(object=self.object)
return self.render_to_response(context)

def htmx_post_merge(self, request, *args, **kwargs):
def htmx_post_merge(self):
self.object = self.get_object()

if self.object.state != "open":
Expand Down Expand Up @@ -265,7 +257,7 @@ class PullRequestDetailView(HTMXViewMixin, DetailView):
return super().get_queryset().filter(users=self.request.user)

# You can also leave off the "bolt-hx-action" attribute and just handle the HTTP method
def htmx_delete(self, request, *args, **kwargs):
def htmx_delete(self):
self.object = self.get_object()

self.object.delete()
Expand Down Expand Up @@ -340,7 +332,7 @@ urlpatterns = [

# views.py
class PullRequestDetailView(HTMXViewMixin, DetailView):
def htmx_post_update(self, request, *args, **kwargs):
def htmx_post_update(self):
self.object = self.get_object()

self.object.update()
Expand Down

0 comments on commit f96e11f

Please sign in to comment.