aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIndrajith K L2024-06-23 05:12:29 +0530
committerIndrajith K L2024-06-23 05:12:29 +0530
commit86277aa6d16cf98f428416f4b759138bb8f128dc (patch)
treee963fbc17c9d318323e22c69e65323b50901b770 /src
parent03867b94387769c0ca32dbfe2d3311ee5ff83afd (diff)
downloadindrajith-dev-crystal-86277aa6d16cf98f428416f4b759138bb8f128dc.tar.gz
indrajith-dev-crystal-86277aa6d16cf98f428416f4b759138bb8f128dc.tar.bz2
indrajith-dev-crystal-86277aa6d16cf98f428416f4b759138bb8f128dc.zip
Fixing Partial rendering in prodution HTMX requests
Diffstat (limited to 'src')
-rw-r--r--src/indrajith-dev-crystal.cr8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/indrajith-dev-crystal.cr b/src/indrajith-dev-crystal.cr
index ed237e3..e11a3f7 100644
--- a/src/indrajith-dev-crystal.cr
+++ b/src/indrajith-dev-crystal.cr
@@ -36,6 +36,12 @@ module Indrajith::Dev::Crystal
context.response.print "Not Found"
end
+ def self.htmx_request?(context)
+ context.request.headers.has_key?("HX-Request") ||
+ context.request.headers.has_key?("Hx-Request") ||
+ context.request.headers.has_key?("hx-request")
+ end
+
get "/" do |context|
context.response.content_type = "text/html"
page_renderer "home", "Home"
@@ -124,7 +130,7 @@ module Indrajith::Dev::Crystal
<p><a href='/post/#{attributes["slug"]}'>#{attributes["post_title"]}</a></p>
</li>"
end
- html_string
+ context.response.print html_string
end
rescue ex
if ex.responds_to?(:response)