This is the hsx Reference Manual, version 0.1.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 06:23:10 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
hsx
Hypertext S-expression
skyizwhite <paku@skyizwhite.dev>
skyizwhite, Bo Yao
MIT
# HSX
HSX (Hypertext S-expression) is a simple yet powerful HTML5 generation library for Common Lisp. It was forked from [flute](https://github.com/ailisp/flute/).
## Introduction
HSX allows you to generate HTML using S-expressions, providing a more Lisp-friendly way to create web content. By using the ‘hsx‘ macro, you can define HTML elements and their attributes in a concise and readable manner.
## Getting Started
### Basic Usage
Use the ‘hsx‘ macro to create HTML elements. Attributes are specified using a property list following the element name, and child elements are nested directly within.
“‘lisp
(hsx
(div :id "example" :class "container"
(h1 "Welcome to HSX")
(p "This is an example paragraph.")))
“‘
This generates:
“‘html
<div id="example" class="container">
<h1>Welcome to HSX</h1>
<p>This is an example paragraph.</p>
</div>
“‘
## Examples
### Dynamic Content
HSX allows embedding Common Lisp code directly within your HTML structure, making it easy to generate dynamic content.
“‘lisp
(hsx
(div
(p :id (format nil "id-~a" (random 100)))
(ul
(loop :for i :from 1 :to 5 :collect (li (format nil "Item ~a" i))))
(if (> (random 10) 5)
(p "Condition met!")
(p "Condition not met!"))))
“‘
This might generate:
“‘html
<div>
<p id="id-42"></p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
</ul>
<p>Condition not met!</p>
</div>
“‘
### Using Fragments
To group multiple elements without adding an extra wrapper, use the fragment ‘<>‘.
“‘lisp
(hsx
(<>
(h1 "Grouped Elements")
(p "First paragraph.")
(p "Second paragraph.")))
“‘
This generates:
“‘html
<h1>Grouped Elements</h1>
<p>First paragraph.</p>
<p>Second paragraph.</p>
“‘
## Creating Components
You can define reusable components with the ‘defcomp‘ macro. Components are functions that can take keyword arguments and properties.
“‘lisp
(defcomp card (&key title children)
(hsx
(div :class "card"
(h1 title)
children)))
“‘
Or using a property list:
“‘lisp
(defcomp card (&rest props)
(hsx
(div :class "card"
(h1 (getf props :title))
(getf props :children))))
“‘
Usage example:
“‘lisp
(hsx
(card :title "Card Title"
(p "This is a card component.")))
“‘
Generates:
“‘html
<div class="card">
<h1>Card Title</h1>
<p>This is a card component.</p>
</div>
“‘
## Rendering HTML
To render HSX to an HTML string, use the ‘render-to-string‘ function.
“‘lisp
(render-to-string
(hsx
(div :class "content"
(h1 "Rendered to String")
(p "This HTML is generated as a string."))))
“‘
## License
This project is licensed under the MIT License.
© 2024 skyizwhite
© 2018 Bo Yao
Feel free to contribute to the project and report any issues or feature requests on the [GitHub repository](https://github.com/skyizwhite/hsx).
0.1.0
hsx/main
(system).
hsx/main
skyizwhite <paku@skyizwhite.dev>
skyizwhite, Bo Yao
MIT
hsx/element
(system).
hsx/dsl
(system).
hsx/builtin
(system).
hsx/element
skyizwhite <paku@skyizwhite.dev>
skyizwhite, Bo Yao
MIT
str
(system).
hsx/utils
(system).
hsx/utils
skyizwhite <paku@skyizwhite.dev>
skyizwhite, Bo Yao
MIT
alexandria
(system).
hsx/dsl
skyizwhite <paku@skyizwhite.dev>
skyizwhite, Bo Yao
MIT
alexandria
(system).
hsx/element
(system).
hsx/builtin
skyizwhite <paku@skyizwhite.dev>
skyizwhite, Bo Yao
MIT
hsx/dsl
(system).
Files are sorted by type and then listed depth-first from the systems components trees.
hsx/hsx.asd
hsx/main/file-type.lisp
hsx/element/file-type.lisp
hsx/utils/file-type.lisp
hsx/dsl/file-type.lisp
hsx/builtin/file-type.lisp
hsx/element/file-type.lisp
hsx/element
(system).
component
(class).
create-element
(function).
element
(class).
element-children
(reader method).
element-props
(reader method).
element-type
(reader method).
expand-component
(method).
fragment
(class).
html-tag
(class).
non-escaping-tag
(class).
print-object
(method).
print-object
(method).
print-object
(method).
print-object
(method).
print-object
(method).
render-to-string
(generic function).
self-closing-tag
(class).
tag
(class).
*non-escaping-tag*
(special variable).
*self-closing-tag*
(special variable).
element-props-with-children
(method).
flatten
(function).
non-escaping-tag-p
(function).
render-children
(method).
render-children
(method).
render-props
(method).
render-type
(method).
self-closing-tag-p
(function).
hsx/utils/file-type.lisp
hsx/utils
(system).
defgroup
(macro).
escape-html-attribute
(function).
escape-html-text-content
(function).
*attribute-escape-map*
(special variable).
*text-content-escape-map*
(special variable).
escape-char
(function).
escape-string
(function).
make-keyword-hash-table
(function).
hsx/dsl/file-type.lisp
hsx/dsl
(system).
%create-element
(function).
defhsx
(macro).
find-builtin-symbols
(function).
parse-body
(function).
hsx/builtin/file-type.lisp
hsx/builtin
(system).
<>
(macro).
a
(macro).
abbr
(macro).
address
(macro).
area
(macro).
article
(macro).
aside
(macro).
audio
(macro).
b
(macro).
base
(macro).
bdi
(macro).
bdo
(macro).
blockquote
(macro).
body
(macro).
br
(macro).
button
(macro).
canvas
(macro).
caption
(macro).
cite
(macro).
code
(macro).
col
(macro).
colgroup
(macro).
data
(macro).
datalist
(macro).
dd
(macro).
del
(macro).
details
(macro).
dfn
(macro).
dialog
(macro).
div
(macro).
dl
(macro).
dt
(macro).
em
(macro).
embed
(macro).
fieldset
(macro).
figcaption
(macro).
figure
(macro).
footer
(macro).
form
(macro).
h1
(macro).
h2
(macro).
h3
(macro).
h4
(macro).
h5
(macro).
h6
(macro).
head
(macro).
header
(macro).
hr
(macro).
html
(macro).
i
(macro).
iframe
(macro).
img
(macro).
input
(macro).
ins
(macro).
kbd
(macro).
label
(macro).
legend
(macro).
li
(macro).
link
(macro).
main
(macro).
map
(macro).
mark
(macro).
meta
(macro).
meter
(macro).
nav
(macro).
noscript
(macro).
object
(macro).
ol
(macro).
optgroup
(macro).
option
(macro).
output
(macro).
p
(macro).
param
(macro).
picture
(macro).
pre
(macro).
progress
(macro).
q
(macro).
rp
(macro).
rt
(macro).
ruby
(macro).
s
(macro).
samp
(macro).
script
(macro).
section
(macro).
select
(macro).
small
(macro).
source
(macro).
span
(macro).
strong
(macro).
style
(macro).
sub
(macro).
summary
(macro).
sup
(macro).
svg
(macro).
table
(macro).
tbody
(macro).
td
(macro).
template
(macro).
textarea
(macro).
tfoot
(macro).
th
(macro).
thead
(macro).
time
(macro).
title
(macro).
tr
(macro).
track
(macro).
u
(macro).
ul
(macro).
var
(macro).
video
(macro).
wbr
(macro).
define-builtin-tags
(macro).
Packages are listed by definition order.
hsx/utils
common-lisp
.
defgroup
(macro).
escape-html-attribute
(function).
escape-html-text-content
(function).
*attribute-escape-map*
(special variable).
*text-content-escape-map*
(special variable).
escape-char
(function).
escape-string
(function).
make-keyword-hash-table
(function).
hsx/builtin
common-lisp
.
<>
(macro).
a
(macro).
abbr
(macro).
address
(macro).
area
(macro).
article
(macro).
aside
(macro).
audio
(macro).
b
(macro).
base
(macro).
bdi
(macro).
bdo
(macro).
blockquote
(macro).
body
(macro).
br
(macro).
button
(macro).
canvas
(macro).
caption
(macro).
cite
(macro).
code
(macro).
col
(macro).
colgroup
(macro).
data
(macro).
datalist
(macro).
dd
(macro).
del
(macro).
details
(macro).
dfn
(macro).
dialog
(macro).
div
(macro).
dl
(macro).
dt
(macro).
em
(macro).
embed
(macro).
fieldset
(macro).
figcaption
(macro).
figure
(macro).
footer
(macro).
form
(macro).
h1
(macro).
h2
(macro).
h3
(macro).
h4
(macro).
h5
(macro).
h6
(macro).
head
(macro).
header
(macro).
hr
(macro).
html
(macro).
i
(macro).
iframe
(macro).
img
(macro).
input
(macro).
ins
(macro).
kbd
(macro).
label
(macro).
legend
(macro).
li
(macro).
link
(macro).
main
(macro).
map
(macro).
mark
(macro).
meta
(macro).
meter
(macro).
nav
(macro).
noscript
(macro).
object
(macro).
ol
(macro).
optgroup
(macro).
option
(macro).
output
(macro).
p
(macro).
param
(macro).
picture
(macro).
pre
(macro).
progress
(macro).
q
(macro).
rp
(macro).
rt
(macro).
ruby
(macro).
s
(macro).
samp
(macro).
script
(macro).
section
(macro).
select
(macro).
small
(macro).
source
(macro).
span
(macro).
strong
(macro).
style
(macro).
sub
(macro).
summary
(macro).
sup
(macro).
svg
(macro).
table
(macro).
tbody
(macro).
td
(macro).
template
(macro).
textarea
(macro).
tfoot
(macro).
th
(macro).
thead
(macro).
time
(macro).
title
(macro).
tr
(macro).
track
(macro).
u
(macro).
ul
(macro).
var
(macro).
video
(macro).
wbr
(macro).
define-builtin-tags
(macro).
hsx/element
common-lisp
.
hsx
.
component
(class).
create-element
(function).
element
(class).
element-children
(generic reader).
element-props
(generic reader).
element-type
(generic reader).
expand-component
(generic function).
fragment
(class).
html-tag
(class).
non-escaping-tag
(class).
render-to-string
(generic function).
self-closing-tag
(class).
tag
(class).
*non-escaping-tag*
(special variable).
*self-closing-tag*
(special variable).
element-props-with-children
(generic function).
flatten
(function).
non-escaping-tag-p
(function).
render-children
(generic function).
render-props
(generic function).
render-type
(generic function).
self-closing-tag-p
(function).
hsx/dsl
common-lisp
.
hsx
.
%create-element
(function).
defhsx
(macro).
find-builtin-symbols
(function).
parse-body
(function).
Definitions are sorted by export status, category, package, and then by lexicographic order.
Define a function component for use in HSX.
The props must be declared with either &key or &rest (or both).
The body must return an HSX element.
Detect built-in HSX elements and automatically import them.
Render an HSX element to a string.
self-closing-tag
) stream) ¶non-escaping-tag
)) ¶Jump to: | %
<
A B C D E F G H I K L M N O P Q R S T U V W |
---|
Jump to: | %
<
A B C D E F G H I K L M N O P Q R S T U V W |
---|
Jump to: | *
C P S T |
---|
Jump to: | *
C P S T |
---|
Jump to: | C E F H N P S T |
---|
Jump to: | C E F H N P S T |
---|