Skip to content

Commit c3160cd

Browse files
committed
initial commit
1 parent d94e457 commit c3160cd

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

main.art

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
;==========================================
2+
; HTML :module
3+
; for Arturo
4+
;
5+
; @file: html.art
6+
; @author: drkameleon
7+
;==========================================
8+
9+
;-------------------------------
10+
; Helper functions
11+
;-------------------------------
12+
13+
shortTag: function [name][
14+
attributes: ""
15+
16+
loop attrs [k,v]->
17+
attributes: attributes ++ ~" |k|='|v|'"
18+
19+
render "<|name||attributes|>"
20+
]
21+
22+
23+
tag: function [name,contents][
24+
tagStart: shortTag name
25+
26+
if? :string = type contents ->
27+
render "|tagStart||contents|</|name|>"
28+
else ->
29+
render "|tagStart||join @contents|</|name|>"
30+
]
31+
32+
;-------------------------------
33+
; Main methods
34+
;-------------------------------
35+
36+
html: $=> tag "html" &
37+
38+
head: $=> tag "head" &
39+
40+
meta: $[X]-> shortTag "meta"
41+
link: $[X]-> shortTag "link"
42+
title: $=> tag "title" &
43+
44+
body: $=> tag "body" &
45+
46+
; Headers
47+
48+
h1: $=> tag "h1" &
49+
h2: $=> tag "h2" &
50+
h3: $=> tag "h3" &
51+
h4: $=> tag "h4" &
52+
h5: $=> tag "h5" &
53+
h6: $=> tag "h6" &
54+
55+
p: $=> tag "p" &
56+
57+
b: $=> tag "b" &
58+
59+
script: $=> tag "script" &

0 commit comments

Comments
 (0)