Add get-element utility
This commit is contained in:
parent
1f588b8a62
commit
fc264bfb2c
2 changed files with 23 additions and 3 deletions
18
README.md
18
README.md
|
@ -46,8 +46,22 @@ It's
|
||||||
```
|
```
|
||||||
|
|
||||||
- Improved:
|
- Improved:
|
||||||
- Element functions are wrapped in macros for natural indentation.
|
- Element functions are wrapped in macros for natural indentation. To manipulate them as function objects, prefix '%' to the element name, or use `get-element` function.
|
||||||
- Bugfix. https://github.com/ailisp/flute/issues/5, https://github.com/ailisp/flute/issues/7
|
- Bugfix. https://github.com/ailisp/flute/issues/5, https://github.com/ailisp/flute/issues/7
|
||||||
|
|
||||||
|
```lisp
|
||||||
|
(define-element dynamic-1 (as)
|
||||||
|
(funcall as props children))
|
||||||
|
|
||||||
|
(define-element dynamic-2 (as)
|
||||||
|
(funcall (get-element as) props children))
|
||||||
|
|
||||||
|
(dynamic-1 :as #'%span :class "bold" "child")
|
||||||
|
(dynamic-2 :as "span" :class "bold" "child")
|
||||||
|
|
||||||
|
; <span class="bold">child</span>
|
||||||
|
```
|
||||||
|
|
||||||
- Removed:
|
- Removed:
|
||||||
- Attributes like CSS selectors (e.g. `div#id.class`)
|
- Attributes like CSS selectors (e.g. `div#id.class`)
|
||||||
- ASCII-based escaping. Piccolo only supports UTF-8.
|
- ASCII-based escaping. Piccolo only supports UTF-8.
|
||||||
|
@ -367,4 +381,4 @@ Licensed under MIT License.
|
||||||
|
|
||||||
Copyright (c) 2024, skyizwhite.
|
Copyright (c) 2024, skyizwhite.
|
||||||
|
|
||||||
Copyright (c) 2018, Bo Yao. All rights reserved.
|
Copyright (c) 2018, Bo Yao.
|
|
@ -37,7 +37,8 @@
|
||||||
#:element-prefix
|
#:element-prefix
|
||||||
#:element-children
|
#:element-children
|
||||||
#:user-element-expand-to
|
#:user-element-expand-to
|
||||||
#:h))
|
#:h
|
||||||
|
#:get-element))
|
||||||
(in-package #:piccolo/elements)
|
(in-package #:piccolo/elements)
|
||||||
|
|
||||||
;;; classes
|
;;; classes
|
||||||
|
@ -279,3 +280,8 @@
|
||||||
(or (html-element-p node) (fragment-p node)))
|
(or (html-element-p node) (fragment-p node)))
|
||||||
(lambda (node)
|
(lambda (node)
|
||||||
(find-symbol (string node) :piccolo)))))
|
(find-symbol (string node) :piccolo)))))
|
||||||
|
|
||||||
|
;;; Utility
|
||||||
|
|
||||||
|
(defun get-element (name)
|
||||||
|
(find-symbol (concatenate 'string "%" (string-upcase name)) :piccolo))
|
||||||
|
|
Loading…
Reference in a new issue