diff options
| author | unwox <me@unwox.com> | 2025-08-31 17:51:57 +0600 |
|---|---|---|
| committer | unwox <me@unwox.com> | 2025-09-04 20:14:11 +0600 |
| commit | 66c51b0e714fa8a1c80784108191270babc8525e (patch) | |
| tree | 0640549f522092096d83c78b9be9b1fa4a03929e /vendor | |
| parent | d8039a77d582f696ab98b2a6d02ce924fbacfa41 (diff) | |
implement shop
Diffstat (limited to 'vendor')
| -rw-r--r-- | vendor/html.fnl | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/vendor/html.fnl b/vendor/html.fnl deleted file mode 100644 index 753bbb9..0000000 --- a/vendor/html.fnl +++ /dev/null @@ -1,32 +0,0 @@ -(local entity-replacements {"&" "&" ; must be first! - "<" "<" - ">" ">" - "\"" """}) - -(local entity-search - (.. "[" (table.concat (icollect [k (pairs entity-replacements)] k)) "]")) - -(fn escape [s] - (assert (= (type s) :string)) - (s:gsub entity-search entity-replacements)) - -(fn tag [tag-name attrs self-closing?] - (assert (= (type attrs) "table") (.. "Missing attrs table: " tag-name)) - (let [attr-str (table.concat (icollect [k v (pairs attrs)] - (if (= v true) k - (.. k "=\"" (escape v)"\""))) " ")] - (.. "<" tag-name " " attr-str (if self-closing? " />" ">")))) - -(fn render [document allow-no-escape?] - (if (= (type document) :string) - (escape document) - (and allow-no-escape? (= (. document 1) :NO-ESCAPE)) - (. document 2) - (let [[tag-name attrs & body] document - self-closing? (= 0 (# body))] - (.. (tag tag-name attrs self-closing?) - (table.concat (icollect [_ element (ipairs body)] - (render element allow-no-escape?)) " ") - (if (not self-closing?) (.. "</" tag-name ">") ""))))) - -{ :render render } |
