) = if (condition) this.with(children) else this
/**
* Appends the tags to the end of this element
@@ -408,7 +408,7 @@
* *
* @return itself for easy chaining
*/
- public fun with(vararg children: Tag): ContainerTag {
+ fun with(vararg children: Tag): ContainerTag {
for (aChildren in children) {
with(aChildren)
}
@@ -419,7 +419,7 @@
* Call with-method based on condition
* [.with]
*/
- public fun condWith(condition: Boolean, vararg children: Tag) = if (condition) this.with(*children) else this
+ fun condWith(condition: Boolean, vararg children: Tag) = if (condition) this.with(*children) else this
/**
* Appends a text tag to this element
@@ -428,7 +428,7 @@
* *
* @return itself for easy chaining
*/
- public fun withText(text: String) = with(Text(text))
+ fun withText(text: String) = with(Text(text))
/**
* Sets a custom attribute
@@ -439,7 +439,7 @@
* *
* @return itself for easy chaining
*/
- public fun attr(attribute: String, value: String?): ContainerTag {
+ fun attr(attribute: String, value: String?): ContainerTag {
setAttribute(attribute, value)
return this
}
@@ -448,7 +448,7 @@
* Call attr-method based on condition
* [.attr]
*/
- public fun condAttr(condition: Boolean, attribute: String, value: String?) = if (condition) attr(attribute, value) else this
+ fun condAttr(condition: Boolean, attribute: String, value: String?) = if (condition) attr(attribute, value) else this
/**
* Render the tag and its children
diff --git a/test/nl/astraeus/tag/BasicTest.kt b/test/nl/astraeus/tag/BasicTest.kt
index 524cb1f..0d48d31 100644
--- a/test/nl/astraeus/tag/BasicTest.kt
+++ b/test/nl/astraeus/tag/BasicTest.kt
@@ -1,14 +1,13 @@
package nl.astraeus.tag
import org.junit.Test
-import kotlin.test.assertTrue
/**
* Created by rnentjes on 20-10-15.
*/
fun form(id: String, inline: Boolean = false): ContainerTag {
- var result = form().withId(id)
+ val result = form().withId(id)
if (inline) {
result.withClass("form-online")
@@ -20,7 +19,7 @@
}
fun textInput(id: String, label: String = "", ph: String = "", value: String = ""): ContainerTag {
- var result = div().withClass("form-group")
+ val result = div().withClass("form-group")
result.with(label(label).attr("for", id))
result.with(input()
@@ -38,29 +37,25 @@
class BasicTest {
@Test fun basicTest() {
- var html = div().with(
+ val html = div().with(
h1("Hello world!")
).with(hr())
- assertTrue {
- html.render().equals("Hello world!
")
- }
+ assert(html.render() == "Hello world!
")
- assertTrue {
- html.render(pretty = true).equals("\n
\n Hello world!\n
\n
\n")
- }
+ assert (html.render(pretty = true) == "\n
\n Hello world!\n
\n
\n")
}
@Test fun bsTest() {
- var form = form("form", inline = true)
+ val form = form("form", inline = true)
form.with(textInput("name", "Name", "Type your name here"))
form.with(textInput("email", "Email", "Type your email here", ""))
println(form.render(pretty=true))
- assertTrue {
- form.render(pretty = true).equals("""""")
- }
var head = head()