11= kotlin-html-dsl image:https://travis-ci.org/daggerok/kotlin-html-dsl.svg?branch=master["Build Status", link="https://travis-ci.org/daggerok/kotlin-html-dsl"]
2+ :toc:
3+ :toc-placement!:
24
35//tag::content[]
46image:https://travis-ci.org/daggerok/kotlin-html-dsl.svg?branch=master["Build Status", link="https://travis-ci.org/daggerok/kotlin-html-dsl"]
57image:https://api.bintray.com/packages/daggerok/daggerok/kotlin-html-dsl/images/download.svg[link="https://bintray.com/bintray/jcenter?filterByPkgName=kotlin-html-dsl"]
68image:https://jitpack.io/v/daggerok/kotlin-html-dsl.svg["JitPack", link="https://jitpack.io/#daggerok/kotlin-html-dsl"]
79
10+ toc::[]
11+
812== description
9- Simple and small Kotlin HTML DSL library.
10- Could be used to build server-side MVC apps
13+
14+ Simplest and small Kotlin HTML DSL library ever. Supports HTML5 standard (and some obsolete HTML4 tags according to link:https://www.quackit.com/html/tags/[that] page)
1115
1216image:https://www.bintray.com/docs/images/bintray_badge_color.png["kotlin-html-dsl", link="https://bintray.com/daggerok/daggerok/kotlin-html-dsl?source=watch"]
1317
14- == other installation variants
15- === gradle bintray.daggerok
16- .gradle setup (build.gradle)
18+ == installation
19+
20+ === gradle
21+
22+ .build.gradle
1723[source,gradle]
1824----
1925repositories {
20- maven { url "https://dl.bintray.com/daggerok/daggerok" }
26+ jcenter() // published to bintray
2127}
2228
2329dependencies {
24- compile "com.github.daggerok:kotlin-html-dsl:0.2.PLUS "
30+ compile "com.github.daggerok:kotlin-html-dsl:0.3.ALL "
2531}
2632----
27- === gradle jitpack
28- .gradle setup (build.gradle)
33+
34+ === maven
35+
36+ .pom.xml
37+ [source,xml]
38+ ----
39+ <repositories>
40+ <repository>
41+ <id>jcentral</id>
42+ <url>https://jcenter.bintray.com</url>
43+ </repository>
44+ </repositories>
45+
46+ <dependencies>
47+ <dependency>
48+ <groupId>com.github.daggerok</groupId>
49+ <artifactId>kotlin-html-dsl</artifactId>
50+ <version>0.3.ALL</version>
51+ </dependency>
52+ </dependencies>
53+ ----
54+
55+ == usage
56+
57+ === text function
58+
59+ .1) Stateful DOM API usage (text function usage):
60+ [source,kotlin]
61+ ----
62+ fun main(args: Array<String>) {
63+ println(
64+ html("lang" to "en") {
65+ head {
66+ meta("charset" to "UTF-8")
67+ title {
68+ text("Kotlin HTML DSL")
69+ }
70+ }
71+ body {
72+ h1 {
73+ text("Hello, World!")
74+ }
75+ }
76+ }
77+ )
78+ }
79+ ----
80+
81+ === innerHTML property
82+
83+ .2) Stateful DOM API usage (innerHTML):
84+ [source,kotlin]
85+ ----
86+ fun main(args: Array<String>) {
87+ println(
88+ html("lang" to "en") {
89+ head {
90+ meta("charset" to "UTF-8")
91+ title {
92+ innerHTML += "Kotlin HTML DSL"
93+ }
94+ }
95+ body {
96+ h1 {
97+ innerHTML += "Hello, World!"
98+ }
99+ }
100+ }
101+ )
102+ }
103+ ----
104+
105+ === plus API
106+
107+ .3) Stateles PLUS API usage:
108+ [source,kotlin]
109+ ----
110+ fun main(args: Array<String>) {
111+ println(
112+ html("lang" to "en") {
113+ head {
114+ meta("charset" to "UTF-8")+
115+ title {
116+ "Kotlin HTML DSL"
117+ }
118+ }+
119+ body {
120+ h1 {
121+ "Hello, World!"
122+ }
123+ }
124+ }
125+ )
126+ }
127+ ----
128+
129+ .all 3 examples will produce same HTML:
130+ [source,html]
131+ ----
132+ <!DOCTYPE html>
133+ <html lang='en'>
134+ <head>
135+ <meta charset='UTF-8'/>
136+ <title>Kotlin HTML DSL</title>
137+ </head>
138+ <body>
139+ <h1>Hello, World!</h1>
140+ </body>
141+ </html>
142+ ----
143+
144+ == tags support
145+
146+ === **HTML5 tags**
147+
148+ _The following tags are supported in HTML5 (and/or the WHATWG HTML Living Standard):_
149+
150+ a
151+ abbr
152+ address
153+ area
154+ article
155+ aside
156+ audio
157+ b
158+ base
159+ bdi
160+ bdo
161+ blockquote
162+ body
163+ br
164+ button
165+ canvas
166+ caption
167+ cite
168+ code
169+ col
170+ colgroup
171+ data
172+ datalist
173+ dd
174+ del
175+ details
176+ dfn
177+ dialog
178+ div
179+ dl
180+ dt
181+ em
182+ embed
183+ fieldset
184+ figcaption
185+ figure
186+ footer
187+ form
188+ h1
189+ h2
190+ h3
191+ h4
192+ h5
193+ h6
194+ head
195+ header
196+ hgroup
197+ hr
198+ html
199+ i
200+ iframe
201+ img
202+ input
203+ ins
204+ kbd
205+ keygen
206+ label
207+ legend
208+ li
209+ link
210+ main
211+ map
212+ mark
213+ menu
214+ menuitem
215+ meta
216+ meter
217+ nav
218+ noscript
219+ object
220+ ol
221+ optgroup
222+ option
223+ output
224+ p
225+ param
226+ pre
227+ progress
228+ q
229+ rb
230+ rp
231+ rt
232+ rtc
233+ ruby
234+ s
235+ samp
236+ script
237+ section
238+ select
239+ small
240+ source
241+ span
242+ strong
243+ style
244+ sub
245+ summary
246+ sup
247+ table
248+ tbody
249+ td
250+ template
251+ textarea
252+ tfoot
253+ th
254+ thead
255+ time
256+ title
257+ tr
258+ track
259+ u
260+ ul
261+ var
262+ video
263+ wbr
264+
265+ === **HTML4 / obsolete tags**
266+
267+ _The following tags are supported in HTML 4 but not HTML5.
268+ Therefore you should not use these if you need to be HTML5 compliant:_
269+
270+ acronym
271+ applet
272+ basefont
273+ big
274+ center
275+ dir
276+ font
277+ frame
278+ frameset
279+ isindex
280+
281+ == other installation variants
282+
283+ === bintray user repository
284+
285+ ==== gradle
286+
287+ .build.gradle
29288[source,gradle]
30289----
31290repositories {
32- maven { url "https://jitpack.io " }
291+ maven { url "https://dl.bintray.com/daggerok/daggerok " }
33292}
34293
35294dependencies {
36- compile "com.github.daggerok:kotlin-html-dsl:0.2.PLUS "
295+ compile "com.github.daggerok:kotlin-html-dsl:0.3.ALL "
37296}
38297----
39- === maven bintray/daggerok
40- .maven setup (pom.xml)
298+
299+ ==== maven
300+
301+ .pom.xml
41302[source,xml]
42303----
43304<repositories>
@@ -51,12 +312,30 @@ dependencies {
51312 <dependency>
52313 <groupId>com.github.daggerok</groupId>
53314 <artifactId>kotlin-html-dsl</artifactId>
54- <version>0.2.PLUS </version>
315+ <version>0.3.ALL </version>
55316 </dependency>
56317</dependencies>
57318----
58- === maven jitpack
59- .maven setup (pom.xml)
319+
320+ === jitpack repository
321+
322+ ==== gradle
323+
324+ .build.gradle
325+ [source,gradle]
326+ ----
327+ repositories {
328+ maven { url "https://jitpack.io" }
329+ }
330+
331+ dependencies {
332+ compile "com.github.daggerok:kotlin-html-dsl:0.3.ALL"
333+ }
334+ ----
335+
336+ ==== maven
337+
338+ .pom.xml
60339[source,xml]
61340----
62341<repositories>
@@ -70,16 +349,18 @@ dependencies {
70349 <dependency>
71350 <groupId>com.github.daggerok</groupId>
72351 <artifactId>kotlin-html-dsl</artifactId>
73- <version>0.2.PLUS </version>
352+ <version>0.3.ALL </version>
74353 </dependency>
75354</dependencies>
76355----
77356
78357== TODO
358+
79359* add examples projects
80360* publish to mavenCentral (TODO)
81361
82362== contribution
363+
83364Feel free extend and contribute to add more functionality.
84365Personally I'd like to keep it simple as possible, but my Kotlin knowledge not yet good enough.
85366So if you can improve it or make it more DSL-ish -- please, create PR
0 commit comments