Skip to content

Commit

Permalink
support vectors in class attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaensel committed Oct 24, 2023
1 parent 57a065d commit 818ab29
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/Layout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ function flexgrid_kwargs(; class = "", class! = nothing, symbol_class::Bool = tr
# while class will contain a js expression as Symbol
# if either class is a Symbol or class! is not nothing.
# So an argument of the form `class! = "'my-class' + 'your-class'` is supported
# Furthermore Vectors are now supported
class isa Vector && (class = Symbol(join(js_attr.(class), " + ")))
class! isa Vector && (class! = join(js_attr.(class!), " + "))

classes = String[]
if class isa Symbol
class! !== nothing && (class = Symbol("$class! + $class"))
Expand Down
11 changes: 6 additions & 5 deletions src/Stipple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -921,15 +921,16 @@ function attributes(kwargs::Union{Vector{<:Pair}, Base.Iterators.Pairs, Dict},
for (k,v) in kwargs
v === nothing && continue
mapped = false

k_str = string(k)

if haskey(mappings, string(k))
k = mappings[string(k)]
if haskey(mappings, k_str)
k_str = mappings[k_str]
end

v_isa_jsexpr = v isa Symbol || !isa(v, Union{AbstractString, Bool, Number})
k_str = string(k)
attr_key = string((v_isa_jsexpr && ! startswith(k_str, ":") &&
! (endswith(k_str, "!") || startswith(k_str, "v-") || startswith(k_str, "v" * Genie.config.html_parser_char_dash)) ? ":" : ""), "$k") |> Symbol
! (endswith(k_str, "!") || startswith(k_str, "v-") || startswith(k_str, "v" * Genie.config.html_parser_char_dash)) ? ":" : ""), k_str) |> Symbol
attr_val = if isa(v, Symbol) && ! startswith(k_str, ":")
Stipple.julia_to_vue(v)
elseif v isa Symbol || ! v_isa_jsexpr
Expand Down

0 comments on commit 818ab29

Please sign in to comment.