Skip to content

Commit

Permalink
Improved format of details examples
Browse files Browse the repository at this point in the history
  • Loading branch information
genericallyterrible committed Feb 8, 2024
1 parent abee9e4 commit 30773e3
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/Layout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -657,22 +657,29 @@ begin
```
```julia
details("My summary", [
"My first item",
(@bind my_var Slider(1:10)),
md"How are you feeling? \$(@bind feeling Slider(1:10))",
])
details(
"My summary",
[
"My first item",
(@bind my_var Slider(1:10)),
md"How are you feeling? \$(@bind feeling Slider(1:10))",
],
open=true,
)
```
!!! warning "Beware @bind in collection declaration"
You may want to `@bind` several variables with `contents` by inlining a collection of `@bind` expressions. Wrap each `@bind` expression in parenthesis or interpolate them in `md` strings like the example above to prevent macro expansion from modifying how your collection declaration is interpreted.
```julia
# This example will cause an error
details("My summary", [
"My first item",
@bind my_var Slider(1:10),
])
details(
"My summary",
[
"My first item",
@bind my_var Slider(1:10),
]
)
```
"""
details
Expand Down Expand Up @@ -779,4 +786,4 @@ export details
# ╟─9cd41081-68ac-4b46-bc78-8d4c028faed9
# ╠═716a13e2-d615-4032-86e9-a2085c95f252
# ╟─c11eafa2-ddce-418b-8a3a-6673392511d0
# ╟─0d6ce65d-dbd0-4016-a052-009911011108
# ╠═0d6ce65d-dbd0-4016-a052-009911011108

0 comments on commit 30773e3

Please sign in to comment.