Skip to content

Commit b4e27b9

Browse files
committed
release: v0.8.2 Thymeleaf Tag Processor now uses the Thymeleaf ViewResolver to render nested ViewComponents allowing to use th:field
1 parent 61b6c99 commit b4e27b9

File tree

20 files changed

+89
-62
lines changed

20 files changed

+89
-62
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ spring.view-component.local-development=true
227227
<summary>Gradle</summary>
228228

229229
```kotlin
230-
implementation("de.tschuehly:spring-view-component-thymeleaf:0.8.1")
230+
implementation("de.tschuehly:spring-view-component-thymeleaf:0.8.2")
231231
sourceSets {
232232
main {
233233
resources {
@@ -249,7 +249,7 @@ sourceSets {
249249
<dependency>
250250
<groupId>de.tschuehly</groupId>
251251
<artifactId>spring-view-component-thymeleaf</artifactId>
252-
<version>0.8.1</version>
252+
<version>0.8.2</version>
253253
</dependency>
254254
</dependencies>
255255
<build>
@@ -286,7 +286,7 @@ plugins {
286286
id("gg.jte.gradle") version("3.1.12")
287287
}
288288

289-
implementation("de.tschuehly:spring-view-component-jte:0.8.1")
289+
implementation("de.tschuehly:spring-view-component-jte:0.8.2")
290290

291291
jte{
292292
generate()
@@ -305,7 +305,7 @@ jte{
305305
<dependency>
306306
<groupId>de.tschuehly</groupId>
307307
<artifactId>spring-view-component-jte</artifactId>
308-
<version>0.8.1</version>
308+
<version>0.8.2</version>
309309
</dependency>
310310
</dependencies>
311311
<build>
@@ -343,7 +343,7 @@ jte{
343343
<summary>Gradle</summary>
344344

345345
```kotlin
346-
implementation("de.tschuehly:spring-view-component-kte:0.8.1")
346+
implementation("de.tschuehly:spring-view-component-kte:0.8.2")
347347
jte{
348348
generate()
349349
sourceDirectory = Path("src/main/kotlin")

core/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ plugins {
88
kotlin("plugin.spring") version "1.9.23"
99

1010
id("maven-publish")
11-
id("org.jreleaser") version "1.11.0"
11+
id("org.jreleaser") version "1.13.0"
1212
id("signing")
1313
id("java-test-fixtures")
1414
}
1515

1616
group = "de.tschuehly"
17-
version = "0.8.1"
17+
version = "0.8.2"
1818
java.sourceCompatibility = JavaVersion.VERSION_17
1919

2020
repositories {

core/src/testFixtures/kotlin/de/tschuehly/spring/viewcomponent/core/IntegrationTestBase.kt

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import org.springframework.boot.test.web.client.TestRestTemplate
88
import org.springframework.http.HttpMethod
99
import org.springframework.http.HttpStatus
1010
import org.springframework.http.ResponseEntity
11+
1112
abstract class IntegrationTestBase {
1213
@Autowired
1314
lateinit var testRestTemplate: TestRestTemplate
15+
1416
@Test
1517
fun testIndexComponent() {
1618
val expectedHtml =
@@ -37,6 +39,9 @@ abstract class IntegrationTestBase {
3739
<div>
3840
<h2>This is the SimpleViewComponent</h2>
3941
<div>Hello World</div>
42+
<div>
43+
<input id="helloWorld" name="helloWorld" value="Hello World">
44+
</div>
4045
</div>
4146
""".trimIndent()
4247
assertEndpointReturns("/simple", expectedHtml)
@@ -45,34 +50,35 @@ abstract class IntegrationTestBase {
4550
@Test
4651
fun testLayoutComponent() {
4752
//language=html
48-
val expectedHtml =
49-
"""
53+
val expectedHtml = """
5054
<html>
5155
<nav>This is a Navbar</nav>
5256
<body>
5357
<div><h2>This is the SimpleViewComponent</h2>
54-
<div>Hello World</div></div></body>
55-
<footer>This is a footer</footer></html>
58+
<div>Hello World</div>
59+
<div>
60+
<input id="helloWorld" name="helloWorld" value="Hello World">
61+
</div>
62+
</div>
63+
</body>
64+
<footer>This is a footer</footer>
65+
</html>
5666
""".trimIndent()
5767
assertEndpointReturns("/layout", expectedHtml)
5868
}
5969

6070
fun assertEndpointReturns(url: String, expectedHtml: String) {
61-
val response: ResponseEntity<String> = this.testRestTemplate
62-
.exchange(url, HttpMethod.GET, null, String::class.java)
63-
assertThat(response.statusCode)
64-
.isEqualTo(HttpStatus.OK)
71+
val response: ResponseEntity<String> =
72+
this.testRestTemplate.exchange(url, HttpMethod.GET, null, String::class.java)
73+
assertThat(response.statusCode).isEqualTo(HttpStatus.OK)
6574
Assertions.assertEquals(
6675
expectedHtml.rmWhitespaceBetweenHtmlTags(), response.body?.rmWhitespaceBetweenHtmlTags()
6776
)
6877
}
6978

7079
fun String.rmWhitespaceBetweenHtmlTags(): String {
7180
// Replace whitespace between > and word
72-
return this.replace("(?<=>)(\\s*)(?=\\w)".toRegex(), "")
73-
.replace("(?<=\\w)(\\s*)(?=<)".toRegex(), "")
74-
.replace("(?<=>)(\\s*)(?=<)".toRegex(), "")
75-
.replace("\r\n","\n")
76-
.trim()
81+
return this.replace("(?<=>)(\\s*)(?=\\w)".toRegex(), "").replace("(?<=\\w)(\\s*)(?=<)".toRegex(), "")
82+
.replace("(?<=>)(\\s*)(?=<)".toRegex(), "").replace("\r\n", "\n").trim()
7783
}
7884
}

examples/.run/Run all example tests.run.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<option name="executionName" />
55
<option name="externalProjectPath" value="$PROJECT_DIR$/examples" />
66
<option name="externalSystemIdString" value="GRADLE" />
7-
<option name="scriptParameters" value="" />
7+
<option name="scriptParameters" value="--stacktrace --stacktrace --stacktrace --stacktrace" />
88
<option name="taskDescriptions">
99
<list />
1010
</option>

examples/jte-example/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ repositories {
2626
dependencies {
2727
implementation("org.springframework.boot:spring-boot-starter-web")
2828

29-
implementation("de.tschuehly:spring-view-component-jte:0.8.1")
29+
implementation("de.tschuehly:spring-view-component-jte:0.8.2")
3030

3131
implementation("org.webjars.npm:htmx.org:1.9.11")
3232
implementation("org.webjars:webjars-locator-core:0.58")
3333

3434
testImplementation("org.springframework.boot:spring-boot-starter-test")
3535
testRuntimeOnly("org.springframework.boot:spring-boot-devtools")
36-
testImplementation(testFixtures("de.tschuehly:spring-view-component-core:0.8.1"))
36+
testImplementation(testFixtures("de.tschuehly:spring-view-component-core:0.8.2"))
3737
}
3838

3939
tasks.withType<Test> {

examples/jte-example/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<description>JTE Example</description>
1616
<properties>
1717
<java.version>17</java.version>
18-
<view.component.version>0.8.1</view.component.version>
18+
<view.component.version>0.8.2</view.component.version>
1919
</properties>
2020
<dependencies>
2121
<dependency>

examples/jte-example/src/main/java/de/tschuehly/example/jte/web/simple/SimpleViewComponent.jte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
<div>
44
<h2>This is the SimpleViewComponent</h2>
55
<div>${simpleView.helloWorld()}</div>
6+
<div>
7+
<input id="helloWorld" name="helloWorld" value="${simpleView.helloWorld()}">
8+
</div>
69
</div>

examples/kte-example/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ repositories {
3131
}
3232

3333
dependencies {
34-
implementation("de.tschuehly:spring-view-component-kte:0.8.1")
35-
implementation("de.tschuehly:spring-view-component-core:0.8.1")
34+
implementation("de.tschuehly:spring-view-component-kte:0.8.2")
35+
implementation("de.tschuehly:spring-view-component-core:0.8.2")
3636
implementation("io.github.wimdeblauwe:htmx-spring-boot:3.1.1")
3737

3838
implementation("org.webjars.npm:htmx.org:1.9.11")
@@ -47,7 +47,7 @@ dependencies {
4747

4848
testImplementation("org.springframework.boot:spring-boot-starter-test")
4949
testImplementation("org.springframework.boot:spring-boot-devtools")
50-
testImplementation(testFixtures("de.tschuehly:spring-view-component-core:0.8.1"))
50+
testImplementation(testFixtures("de.tschuehly:spring-view-component-core:0.8.2"))
5151
}
5252

5353
tasks.withType<KotlinCompile> {

examples/kte-example/src/main/kotlin/de/tschuehly/kteviewcomponentexample/web/simple/SimpleViewComponent.kte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
<div>
33
<h2>This is the SimpleViewComponent</h2>
44
<div>${simpleView.helloWorld}</div>
5+
<div>
6+
<input id="helloWorld" name="helloWorld" value="${simpleView.helloWorld}">
7+
</div>
58
</div>

examples/thymeleaf-java-example/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ repositories {
2929

3030
dependencies {
3131
implementation("org.springframework.boot:spring-boot-starter-web")
32-
implementation("de.tschuehly:spring-view-component-thymeleaf:0.8.1")
32+
implementation("de.tschuehly:spring-view-component-thymeleaf:0.8.2")
3333

3434
implementation("org.webjars.npm:htmx.org:1.9.11")
3535
implementation("org.webjars:webjars-locator-core:0.58")
3636

3737
testImplementation("org.springframework.boot:spring-boot-starter-test")
3838
testImplementation("org.springframework.boot:spring-boot-devtools")
39-
testImplementation(testFixtures("de.tschuehly:spring-view-component-core:0.8.1"))
39+
testImplementation(testFixtures("de.tschuehly:spring-view-component-core:0.8.2"))
4040
}
4141

4242
tasks.withType<Test> {

0 commit comments

Comments
 (0)