use Cro::HTTP::Router;
use Cro::WebApp::Template;
sub happy_tm_xmas-routes() is export {
route {
$cromponent.add: Results, ActiveTable, THead, HCell, Row, Cell;
get -> {
template-with-components $cromponent, $index, $topic;
}
post -> 'search' {
my $needle;
request-body -> %fields {
$needle = %fields<search>;
}
template-with-components $cromponent, results( results => search($needle), :$topic), $topic;
}
}
}
sub search($needle) {
sub check($str) { $str.contains($needle, :i) };
data.grep: (
*.<firstName>.&check,
*.<lastName>.&check,
*.<email>.&check,
).any;
}
use JSON::Fast;
sub data() {
from-json q:to/END/;
[
{"firstName": "Venus", "lastName": "Grimes", "email": "[email protected]", "city": "Ankara"},
{"firstName": "Fletcher", "lastName": "Owen", "email": "[email protected]", "city": "Niort"},
{"firstName": "William", "lastName": "Hale", "email": "[email protected]", "city": "Te Awamutu"},
{"firstName": "TaShya", "lastName": "Cash", "email": "[email protected]", "city": "Titagarh"},
...
]
END
}
Last active
December 17, 2024 12:12
-
-
Save librasteve/889c6e3fd7742cfbee51b1efb46f712f to your computer and use it in GitHub Desktop.
htmxas3.md
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment