Skip to content

Ideas for additional content#2

Open
seanterry wants to merge 1 commit intokhalidabuhakmeh:mainfrom
seanterry:tweaks
Open

Ideas for additional content#2
seanterry wants to merge 1 commit intokhalidabuhakmeh:mainfrom
seanterry:tweaks

Conversation

@seanterry
Copy link

Contributing back a few things I've learned along the way using Blazor Static SSR with HTMX.

I added a middleware to check whether we are in an HTMX request. Since this project has some server interactivity, I felt that was safer than trying to use IHttpContextAccessor.

App.razor and MainLayout.razor now short-circuit to avoid a complete render during HTMX requests. This allows LoveHtmx.razor to be routable rather than needing an API call.

I've found that the syntax of writing minimal APIs gets a bit clunky, particularly when capturing form data. I added an example of using a Controller with a RazorComonentResult, which I am affectionately dubbing "Model-Blazor-Controller".

This results in demonstrating four ways to call the LoveHtmx component:

  • As a component
  • Static SSR
  • HTMX via the same route
  • As a controller action

I also bumped HTMX to 2.0 while listening to the upgrade music

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant