diff --git a/src/Elements.jl b/src/Elements.jl index 32e9d09c..380772db 100644 --- a/src/Elements.jl +++ b/src/Elements.jl @@ -328,7 +328,7 @@ Sometimes preprocessing of the events is necessary, e.g. to add or skip informat ``` """ macro on(arg, expr, preprocess = nothing) - kw = Symbol("v-on:", arg isa String ? arg : arg isa QuoteNode ? arg.value : arg.head == :vect ? join(lstrip.(string.(arg.args), ':'), '.') : + kw = Symbol("v-on:", arg isa String ? arg : arg isa QuoteNode ? arg.value : arg.head == :vect ? join(lstrip.(string.(arg.args), ':'), '.') : throw("Value '$arg' for `arg` not supported. `arg` should be of type Symbol, String, or Vector{Union{String, Symbol}}")) isevent = expr isa QuoteNode && expr.value isa Symbol diff --git a/src/ReactiveTools.jl b/src/ReactiveTools.jl index 5dfd0159..79d2e148 100644 --- a/src/ReactiveTools.jl +++ b/src/ReactiveTools.jl @@ -35,8 +35,9 @@ const TYPES = LittleDict{Module,Union{<:DataType,Nothing}}() const HANDLERS_FUNCTIONS = LittleDict{Type{<:ReactiveModel},Function}() -function DEFAULT_LAYOUT(; title::String = "Genie App", meta::Dict{<:AbstractString,<:AbstractString} = Dict("og:title" => "Genie App")) - tags = Genie.Renderers.Html.for_each(x -> """\n """, meta) +function DEFAULT_LAYOUT(; title::String = "Genie App", + meta::D = Dict()) where {D <:AbstractDict} + tags = Genie.Renderers.Html.for_each(x -> """\n""", meta) """ @@ -676,7 +677,7 @@ macro handlers(typename, expr, handlers_fn_name = :handlers) i_start = i + 1 end end - + # model_to_storage is only needed when we add variables to an existing type. no_new_vars = findfirst(x -> x isa Expr, initcode.args) === nothing # if we redefine a type newtype is true @@ -1038,14 +1039,14 @@ for f in (:methods, :watch, :computed) @$($f_str)(App, expr) Defines js functions for the `$($f_str)` section of the vue element. - + `expr` can be - `String` containing javascript code - `Pair` of function name and function code - `Function` returning String of javascript code - `Dict` of function names and function code - `Vector` of the above - + ### Example 1 ```julia diff --git a/src/Stipple.jl b/src/Stipple.jl index 1f9ac9b7..c899ef94 100644 --- a/src/Stipple.jl +++ b/src/Stipple.jl @@ -29,10 +29,10 @@ will import all names from Parent.MyModule except `x` and `y`. Currently suports macro using_except(expr) # check validity expr isa Expr && (expr.args[1] == :(:) || (expr.args[1].head == :call && expr.args[1].args[1] == :(:))) || return - + # determine module name and list of excluded symbols m, excluded = expr.args[1] == :(:) ? (expr.args[2], Symbol[expr.args[3]]) : (expr.args[1].args[2], Symbol[s for s in vcat([expr.args[1].args[3]], expr.args[2:end])]) - + # convert m.args to list of Symbols if m isa Expr m.args[2] = m.args[2].value @@ -41,9 +41,9 @@ macro using_except(expr) m.args[2] = m.args[2].args[2].value end end - + m_name = m isa Expr ? m.args[end] : m - + # as a first step use only the module name # by constructing `using Parent.MyModuleName: MyModule` expr = :(using dummy1: dummy2) @@ -61,7 +61,7 @@ macro using_except(expr) # re-use previous expression and insert the names to be imported expr.args[1].args = pushfirst!(args, expr.args[1].args[1]) - + @debug(expr) expr end @@ -460,7 +460,7 @@ function init(::Type{M}; try haskey(payload, "sesstoken") && ! isempty(payload["sesstoken"]) && - Genie.Router.params!(Stipple.ModelStorage.Sessions.GenieSession.PARAMS_SESSION_KEY, + Genie.Router.params!(:session, Stipple.ModelStorage.Sessions.GenieSession.load(payload["sesstoken"] |> Genie.Encryption.decrypt)) catch ex @error ex diff --git a/src/stipple/rendering.jl b/src/stipple/rendering.jl index db193a63..c7127fc4 100644 --- a/src/stipple/rendering.jl +++ b/src/stipple/rendering.jl @@ -1,5 +1,5 @@ """ - join_js(xx, delim = ""; skip_empty = true, pre::Function = identity, + join_js(xx, delim = ""; skip_empty = true, pre::Function = identity, strip_delimiter = true, pre_delim::Union{Function,Nothing} = nothing) Join elements of an iterator similar to [`join`](@ref) with additonal features @@ -86,7 +86,7 @@ function julia_to_vue(field, mapping_keys = mapping_keys()) :: String extraparts = map((x) -> uppercasefirst(string(x)), parts[2:end]) string(parts[1], join(extraparts)) else - parts |> string + join(parts) |> string end else field |> string