Skip to content

Commit

Permalink
Add extra info in README about using multiple values in hx-vals
Browse files Browse the repository at this point in the history
  • Loading branch information
wimdeblauwe committed May 5, 2024
1 parent a8b65ab commit 6f75d1f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,13 @@ will render as:

(Given `user.id` has the value `1234`)

You can use multiple values like this:

```html

<div hx:vals="${ {id: user.id, groupId: group.id } }"></div>
```

## Articles

Links to articles and blog posts about this library:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ void testWithHxVals() throws Exception {
assertThat(html)
.containsPattern("hx-vals-div-boolean.*hx-vals=\"\\{&quot;someBooleanProperty&quot;:true}\"")
.containsPattern("hx-vals-div-string.*hx-vals=\"\\{&quot;someStringProperty&quot;:&quot;someString&quot;}\"")
.containsPattern("hx-vals-div-number.*hx-vals=\"\\{&quot;someNumberProperty&quot;:12345}\"");
.containsPattern("hx-vals-div-number.*hx-vals=\"\\{&quot;someNumberProperty&quot;:12345}\"")
.containsPattern("hx-vals-div-multiple.*hx-vals=\"\\{&quot;someBooleanProperty&quot;:true,&quot;someNumberProperty&quot;:12345}\"");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<div id="hx-vals-div-boolean" hx:vals="${ {someBooleanProperty: trueVariable} }"></div>
<div id="hx-vals-div-string" hx:vals="${ {someStringProperty: stringVariable} }"></div>
<div id="hx-vals-div-number" hx:vals="${ {someNumberProperty: numberVariable} }"></div>
<div id="hx-vals-div-multiple"
hx:vals="${ {someBooleanProperty: trueVariable, someNumberProperty: numberVariable} }"></div>
<div id="hx-swap-div-with-empty-string" hx:swap="${falseVariable}?'afterend':''"></div>
<div id="hx-swap-div-with-null" hx:swap="${falseVariable}?'afterend':null"></div>
<div id="hx-swap-div-with-th-with" th:with="sum = ${1+1}" hx:swap="${sum.equals(2)}?'afterend':null"></div>
Expand Down

0 comments on commit 6f75d1f

Please sign in to comment.