From b31d573d2f7f8af04803e1eaa7377ad61b10b164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helmut=20H=C3=A4nsel?= Date: Tue, 24 Oct 2023 00:04:24 +0200 Subject: [PATCH] add automatic json conversion for attributes --- src/Stipple.jl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Stipple.jl b/src/Stipple.jl index a7a1c084..b8f57afe 100644 --- a/src/Stipple.jl +++ b/src/Stipple.jl @@ -926,10 +926,16 @@ function attributes(kwargs::Union{Vector{<:Pair}, Base.Iterators.Pairs, Dict}, k = mappings[string(k)] end - attr_key = string((isa(v, Symbol) && ! startswith(string(k), ":") && + v_isa_jsexpr = v isa Symbol || !isa(v, Union{AbstractString, Bool, Number}) + attr_key = string((v_isa_jsexpr && ! startswith(string(k), ":") && ! ( startswith(string(k), "v-") || startswith(string(k), "v" * Genie.config.html_parser_char_dash) ) ? ":" : ""), "$k") |> Symbol - attr_val = isa(v, Symbol) && ! startswith(string(k), ":") ? Stipple.julia_to_vue(v) : v - + attr_val = if isa(v, Symbol) && ! startswith(string(k), ":") + Stipple.julia_to_vue(v) + elseif v isa Symbol || ! v_isa_jsexpr + v + else + js_attr(v) + end attrs[attr_key] = attr_val end