Use cl-str instead
This commit is contained in:
parent
53a6a8f50e
commit
7ce7751900
6 changed files with 26 additions and 34 deletions
4
qlfile
4
qlfile
|
@ -1,4 +1,6 @@
|
|||
ql alexandria
|
||||
ql mstrings
|
||||
ql cl-str
|
||||
|
||||
github rove fukamachi/rove
|
||||
github dissect Shinmera/dissect ; workaround
|
||||
ql mstrings
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
(:class qlot/source/ql:source-ql
|
||||
:initargs (:%version :latest)
|
||||
:version "ql-2023-10-21"))
|
||||
("mstrings" .
|
||||
("cl-str" .
|
||||
(:class qlot/source/ql:source-ql
|
||||
:initargs (:%version :latest)
|
||||
:version "ql-2023-10-21"))
|
||||
|
@ -18,3 +18,7 @@
|
|||
(:class qlot/source/github:source-github
|
||||
:initargs (:repos "Shinmera/dissect" :ref nil :branch nil :tag nil)
|
||||
:version "github-a70cabcd748cf7c041196efd711e2dcca2bbbb2c"))
|
||||
("mstrings" .
|
||||
(:class qlot/source/ql:source-ql
|
||||
:initargs (:%version :latest)
|
||||
:version "ql-2023-10-21"))
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
(defpackage #:hsx/element
|
||||
(:use #:cl)
|
||||
(:import-from #:str
|
||||
#:collapse-whitespaces)
|
||||
(:import-from #:hsx/utils
|
||||
#:defgroup
|
||||
#:escape-html-attribute
|
||||
#:escape-html-text-content
|
||||
#:minify)
|
||||
#:escape-html-text-content)
|
||||
(:export #:element
|
||||
#:tag
|
||||
#:html-tag
|
||||
|
@ -126,7 +127,7 @@
|
|||
(string-downcase (element-type element)))
|
||||
|
||||
(defmethod render-props ((element tag))
|
||||
(minify
|
||||
(collapse-whitespaces
|
||||
(with-output-to-string (stream)
|
||||
(loop
|
||||
:for (key value) :on (element-props element) :by #'cddr
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#:symbolicate)
|
||||
(:export #:escape-html-attribute
|
||||
#:escape-html-text-content
|
||||
#:minify
|
||||
#:defgroup))
|
||||
(in-package #:hsx/utils)
|
||||
|
||||
|
@ -43,23 +42,6 @@
|
|||
(defun escape-html-attribute (str)
|
||||
(escape-string str *attribute-escape-map*))
|
||||
|
||||
(defun minify (str)
|
||||
(with-output-to-string (out)
|
||||
(let ((previous-space-p nil))
|
||||
(loop
|
||||
:for char :across str
|
||||
:do (cond
|
||||
((whitespace-p char)
|
||||
(unless previous-space-p
|
||||
(write-char #\Space out))
|
||||
(setf previous-space-p t))
|
||||
(t
|
||||
(write-char char out)
|
||||
(setf previous-space-p nil)))))))
|
||||
|
||||
(defun whitespace-p (char)
|
||||
(member char '(#\Space #\Newline #\Tab #\Return) :test #'char=))
|
||||
|
||||
(defun make-keyword-hash-table (symbols)
|
||||
(let ((ht (make-hash-table)))
|
||||
(mapcar (lambda (sym)
|
||||
|
|
|
@ -89,6 +89,7 @@
|
|||
nil
|
||||
"bar")))
|
||||
:pretty t))))
|
||||
|
||||
(testing "self-closing-tag"
|
||||
(ok (string= "<img src=\"/background.png\">"
|
||||
(render-to-string (create-element :img
|
||||
|
@ -137,7 +138,18 @@
|
|||
(create-element :li
|
||||
nil
|
||||
(list "brah"))))
|
||||
:pretty t))))))
|
||||
:pretty t)))))
|
||||
|
||||
(testing "minify-props-text"
|
||||
(let ((elm (create-element :div
|
||||
'(:x-data "{
|
||||
open: false,
|
||||
get isOpen() { return this.open },
|
||||
toggle() { this.open = ! this.open },
|
||||
}")
|
||||
nil)))
|
||||
(ok (string= (render-to-string elm)
|
||||
"<div x-data=\"{ open: false, get isOpen() { return this.open }, toggle() { this.open = ! this.open }, }\"></div>")))))
|
||||
|
||||
(defun comp1 (&key prop children)
|
||||
(create-element :div
|
||||
|
|
|
@ -11,16 +11,7 @@
|
|||
|
||||
(testing "escape-html-text-content"
|
||||
(ok (string= "&<>"'/`="
|
||||
(escape-html-text-content "&<>\"'/`="))))
|
||||
|
||||
(testing "minify"
|
||||
;; Test with Alpine.js
|
||||
(ok (string= (minify "{
|
||||
open: false,
|
||||
get isOpen() { return this.open },
|
||||
toggle() { this.open = ! this.open },
|
||||
}")
|
||||
"{ open: false, get isOpen() { return this.open }, toggle() { this.open = ! this.open }, }"))))
|
||||
(escape-html-text-content "&<>\"'/`=")))))
|
||||
|
||||
(defgroup fruit
|
||||
apple banana)
|
||||
|
|
Loading…
Reference in a new issue