Skip to content

Commit

Permalink
improve docstring for js_attr
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaensel committed Oct 21, 2023
1 parent 6b5da19 commit d1bb17f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/stipple/rendering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@ end
js_attr(x)
Renders a Julia expression as Javascript Expression that can be passed as an attribute value in html elements.
### Example
```
using StippleUI
quasar(
:btn__toggle,
fieldname = :btn_value,
options = js_attr([opts(label = "Off", value = false), opts(label = "On", value = true)])
)
# "<q-btn-toggle v-model=\\"btn_value\\" :options=\\"[{'value':false,'label':'Off'}, {'value':true,'label':'On'}]\\"></q-btn-toggle>"
```
"""
function js_attr(x)
Symbol(replace(json(render(x)), "'" => raw"\'", '"' => '''))
Expand Down

0 comments on commit d1bb17f

Please sign in to comment.