Fixing Partial rendering in prodution HTMX requests
This commit is contained in:
@@ -36,6 +36,12 @@ module Indrajith::Dev::Crystal
|
|||||||
context.response.print "Not Found"
|
context.response.print "Not Found"
|
||||||
end
|
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|
|
get "/" do |context|
|
||||||
context.response.content_type = "text/html"
|
context.response.content_type = "text/html"
|
||||||
page_renderer "home", "Home"
|
page_renderer "home", "Home"
|
||||||
@@ -124,7 +130,7 @@ module Indrajith::Dev::Crystal
|
|||||||
<p><a href='/post/#{attributes["slug"]}'>#{attributes["post_title"]}</a></p>
|
<p><a href='/post/#{attributes["slug"]}'>#{attributes["post_title"]}</a></p>
|
||||||
</li>"
|
</li>"
|
||||||
end
|
end
|
||||||
html_string
|
context.response.print html_string
|
||||||
end
|
end
|
||||||
rescue ex
|
rescue ex
|
||||||
if ex.responds_to?(:response)
|
if ex.responds_to?(:response)
|
||||||
|
|||||||
Reference in New Issue
Block a user