NAME
Uniform::HTMX::Mojolicious - Framework-agnostic htmx adapter for Mojolicious
SYNOPSIS
use Mojolicious::Lite;
use Uniform::HTMX::Mojolicious;
get '/time' => sub {
my $c = shift;
my $htmx = Uniform::HTMX::Mojolicious->new($c);
if ($htmx->is_htmx) {
$htmx->res_reswap('innerHTML')
->res_trigger('timeUpdated', { time => scalar localtime });
$htmx->apply($c);
return $c->render(text => '<div>Time updated!</div>');
}
$c->render(text => 'Standard non-htmx request');
};
app->start;
DESCRIPTION
Uniform::HTMX::Mojolicious bridges the Uniform::HTMX base protocol engine with the Mojolicious web framework. It automatically extracts incoming HX-* HTTP request headers from Mojolicious::Controller objects and provides a clean pipeline for queuing and applying outbound htmx response headers directly to the controller's response object.
METHODS
new
my $htmx = Uniform::HTMX::Mojolicious->new($c);
Constructs a new instance. Requires a valid Mojolicious::Controller object. Inbound headers are normalized and passed directly to the Uniform::HTMX base constructor.
apply
$htmx->apply($c);
Injects all accumulated outbound htmx response headers (such as HX-Trigger, HX-Reswap, HX-Redirect, etc.) into the controller's Mojo::Headers response object via $c->res->headers. Returns the controller object.
INHERITED METHODS
This package inherits directly from Uniform::HTMX. All request inspection and response manipulation methods provided by Uniform::HTMX are fully available:
is_htmxtargettrigger_namecurrent_urlres_trigger($event, $payload)res_reswap($swap_mode)res_redirect($url)
SEE ALSO
AUTHOR
Joshua S. Day <HAX@cpan.org>
LICENSE AND COPYRIGHT
This software is Copyright (c) 2026 by Joshua S. Day.
This is free software, licensed under:
The MIT (X11) License