Skip to content

Commit 8da78aa

Browse files
committed
[html\gen] move file and turn it into a module
1 parent 69449de commit 8da78aa

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed
Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11

2-
_kebab: $[content :string][
2+
export module ::
3+
4+
kebab: method [content :string][
35
replace content "_" "-"
46
]
57

6-
voidElement: $[tag :string :literal :word htmlAttributes :dictionary][
7-
;; Void elements are elements without closing-tags.
8+
voidElement: method [tag :string :literal :word htmlAttributes :dictionary][
9+
;; Void \elements are \elements without closing-tags.
810
;;
911
;; Format
1012
;; ------
@@ -16,21 +18,21 @@ voidElement: $[tag :string :literal :word htmlAttributes :dictionary][
1618
;;
1719
;; Extra
1820
;; -----
19-
;; Read more about void elements here:
20-
;; <https://html.spec.whatwg.org/multipage/syntax.html#void-elements/>
21+
;; Read more about void \elements here:
22+
;; <https://html.spec.whatwg.org/multipage/syntax.html#void-\elements/>
2123

2224
attributes: (
23-
map htmlAttributes [key value] -> render {|_kebab key|="|value|"}
24-
| append (map attrs [key value] -> render {|_kebab key|="|value|"})
25+
map htmlAttributes [key value] -> render {|\kebab key|="|value|"}
26+
| append (map attrs [key value] -> render {|\kebab key|="|value|"})
2527
| join.with: " "
2628
)
2729

2830
if attributes <> "" -> prepend 'attributes " "
2931
~"<|tag||attributes|/>"
3032
]
3133

32-
element: $[tag :string :literal :word content :block :string :dictionary][
33-
;; Elements refers to the normal elements defined by the HTML5 standard.
34+
element: method.public [tag :string :literal content :block :string :dictionary][
35+
;; \elements refers to the normal \elements defined by the HTML5 standard.
3436
;;
3537
;; Format
3638
;; ------
@@ -43,13 +45,13 @@ element: $[tag :string :literal :word content :block :string :dictionary][
4345
;;
4446
;; Extra
4547
;; -----
46-
;; Read more about elements here:
47-
;; <https://html.spec.whatwg.org/multipage/syntax.html#elements-2/>
48+
;; Read more about \elements here:
49+
;; <https://html.spec.whatwg.org/multipage/syntax.html#\elements-2/>
4850

4951
if dictionary? content ->
50-
return voidElement tag content
52+
return \voidElement tag content
5153

52-
attributes: (join.with: " " map attrs [key value] -> render {|_kebab key|="|value|"})
54+
attributes: (join.with: " " map attrs [key value] -> render {|\kebab key|="|value|"})
5355
if attributes <> "" -> prepend 'attributes " "
5456

5557
if block? content ->
@@ -61,11 +63,4 @@ element: $[tag :string :literal :word content :block :string :dictionary][
6163

6264
if string? content ->
6365
~"<|tag||attributes|>|content|</|tag|>"
64-
]
65-
66-
newElement: $[tag :string :literal :word][
67-
head: [content :string :block :dictionary]
68-
body: [element] ++ (@[tag]) ++ [content]
69-
70-
function head body
7166
]

0 commit comments

Comments
 (0)