-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to easily generate dynamic content #40
Comments
With the latest changes of Stipple, this has become incredibly easy: @app begin
@in params = Dict{String, Any}("T_max" => 310.0, "n_segs" => "10", "l_tube" => 10.0, "T_ambient_res" => "Ambient Temperature is 100.0K")
end
function ui()
[
card(class = "q-pa-md",
textfield(class = "q-ma-md", :k, R"params[k]", @for((v, k) in :params))
)
]
end
@page("/", ui)
up() EDIT:
static_params = Dict{String, Any}("T_max" => 310.0, "n_segs" => "10", "l_tube" => 10.0, "T_ambient_res" => "T is 100.0K")
param_keys = keys(static_params)
textfield(:k, R"params[k]", @for((v, k) in static_params))
# "<q-input v-for=\"(v, k) in {'T_max':310.0,'n_segs':'10','l_tube':10.0,'T_ambient_res':'T is 100.0K'}\" :label=\"k\" v-model=\"params[k]\"></q-input>"
# note the inverted order of `(v, k)` in javascript compared with Julia syntax
textfield(:k, R"params[k]", @for(k in param_keys))
"<q-input v-for=\"k in [:a, :c]\" :label=\"k\" v-model=\"params(k)\"></q-input>"
# "<q-input v-for=\"(v, k) in ['T_max', 'n_segs', 'l_tube', 'T_ambient_res']\" :label=\"k\" v-model=\"params[k]\"></q-input>" |
Beautiful! |
I'm happy that you like the new syntax, although you were hesitant in the beginning. It took a while to find out how to best implement Julia expressions but now we are well set, I think. I particularly like the automatic expansion of keys. |
@cwiese Hope this is still helpful for you. You can close the issue if you are ok with the answer. |
We could close this, right? |
I have a Dict in the model (that can change)
in the UI - would like to create many
textfield
..and rerender when model changesObviously @Bind(:params)] does not work.
I was hoping not to create a giant HTML string in the model - but rather use this like a template.
Any ideas
Chuck
The text was updated successfully, but these errors were encountered: