feat(compat): sweep of components against the real core with strict diagnostics
This commit is contained in:
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
# Smoke HTTP del paquete htmx. Recibe BASE, PKG, RESULTS.
|
||||
set -u
|
||||
|
||||
check() {
|
||||
local comp="$1" path="$2" expect="$3" body
|
||||
if ! body="$(curl -fsS "$BASE$path" 2>/dev/null)"; then
|
||||
echo "$PKG:$comp|fail" >> "$RESULTS"; return
|
||||
fi
|
||||
if printf '%s' "$body" | grep -qF "$expect"; then
|
||||
echo "$PKG:$comp|ok" >> "$RESULTS"
|
||||
else
|
||||
echo " inesperado en $path: $(printf '%s' "$body" | head -c 200)" >&2
|
||||
echo "$PKG:$comp|fail" >> "$RESULTS"
|
||||
fi
|
||||
}
|
||||
|
||||
check htmlComponent /compat/htmx/render '<h1 id="compat-greet">A<b></h1>'
|
||||
check htmx /compat/htmx/static 'HTMX:false:true'
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
// Router de compatibilidad del paquete htmx: monta un componente propio sobre
|
||||
// el motor HTMLComponent/HTMX con el arranque real del core.
|
||||
|
||||
use Libs\HTMLComponent;
|
||||
use Libs\HTMX;
|
||||
use Libs\Router;
|
||||
|
||||
$views = ROOT_CORE . '/Views';
|
||||
if (!is_dir($views)) {
|
||||
mkdir($views, 0777, true);
|
||||
}
|
||||
|
||||
file_put_contents($views . '/CompatGreet.php', <<<'VIEW'
|
||||
<h1 id="compat-greet"><?php echo $this->escapedProperty('name'); ?></h1>
|
||||
VIEW);
|
||||
|
||||
file_put_contents($views . '/CompatButton.php', <<<'VIEW'
|
||||
<button hx-post="/compat/htmx/echo" hx-target="#compat-greet" class="btn">ir</button>
|
||||
VIEW);
|
||||
|
||||
Router::get('/compat/htmx/render', function () {
|
||||
echo 'GREET:';
|
||||
HTMLComponent::render('CompatGreet', ['name' => 'A<b>']);
|
||||
});
|
||||
|
||||
Router::get('/compat/htmx/static', function () {
|
||||
$instance = new HTMX([], '<i hx-get="/x">ok</i>');
|
||||
header('X-Marker: ' . (HTMX::isHtmx() ? 'yes' : 'no'));
|
||||
echo 'HTMX:' . var_export(HTMX::isPartialRequest(), true)
|
||||
. ':' . var_export($instance->getContent() !== '', true);
|
||||
});
|
||||
Reference in New Issue
Block a user