From 5f70ee31bb395b081553d3477af559ee79623e63 Mon Sep 17 00:00:00 2001 From: paku Date: Mon, 27 May 2024 18:40:50 +0900 Subject: [PATCH] Add description of children property --- README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 19d66e6..1091c20 100644 --- a/README.md +++ b/README.md @@ -56,13 +56,15 @@ Elements in HSX are essentially functions, so you can freely compose them and em To define a component, just define a function that accepts keyword arguments or property list or both, and define HSX element with `defhsx` macro. +`children` is a special property that accepts children of a component. + ```lisp (defhsx card #'%card) -(defun %card (&key title description) +(defun %card (&key title children) (hsx (div (h1 title) - (p description)))) + children))) or @@ -71,9 +73,11 @@ or (hsx (div (h1 (getf props :title)) - (p (getf props :description))))) + (getf props :children)))) -(hsx (card :title "card1" :description "brah brah brah...")) +(hsx + (card :title "card1" + (p "brah brah brah..."))) ↓ ↓ ↓ @@ -86,11 +90,11 @@ or The previous definition can be simplified by using the `defcomp` macro. ```lisp -(defcomp card (&key title description) +(defcomp card (&key title children) (hsx (div (h1 title) - (p description)))) + children))) ``` # License