HTML response detection and script injection.
HTML response detection and script injection.
(full-html-page? body)Returns true if the string body contains an <html tag, indicating a full HTML document rather than a partial/fragment (e.g. htmx or datastar response).
Returns true if the string body contains an <html tag, indicating a full HTML document rather than a partial/fragment (e.g. htmx or datastar response).
(html-response? {:keys [headers]})Returns true if the response has a text/html content type.
Returns true if the response has a text/html content type.
(inject-into-response response script)If the response is a full HTML page with a string body, injects the script. Partial HTML fragments (e.g. htmx/datastar responses) are left untouched. Returns the modified response, or the original if not applicable.
If the response is a full HTML page with a string body, injects the script. Partial HTML fragments (e.g. htmx/datastar responses) are left untouched. Returns the modified response, or the original if not applicable.
(inject-script body script)Injects a <script> tag into an HTML response body string. Inserts before </body> if present, otherwise appends to end.
Injects a <script> tag into an HTML response body string. Inserts before </body> if present, otherwise appends to end.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |