Skip to content

Commit

Permalink
exclude empty mixins from being included
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaensel committed Nov 29, 2023
1 parent d746977 commit bac3368
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Stipple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,8 @@ function injectdeps(output::Vector{AbstractString}, M::Type{<:ReactiveModel}) ::
mixinfields = fieldnames(Stipple.get_concrete_type(mixin))
# if all fields are already part of the model, don't include data
mode = isempty(setdiff(mixinfields, modelfields)) ? :mixindeps : :mixin
push!(output, mixin_dep(mixin; mode)())
out = mixin_dep(mixin; mode)()
out === nothing || push!(output, out)
end
output
end
Expand Down
7 changes: 6 additions & 1 deletion src/stipple/rendering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,12 @@ function get_mixins(app::ReactiveModel)::Vector{ReactiveModel}
end

function mixin_dep(Mixin::Type{<:ReactiveModel}; mode::Symbol = :mixindeps)
mixin_dep() = script("const $(nameof(Mixin)) = $(strip(json(render(Mixin(); mode)), '"'))\n")
mix = strip(json(render(Mixin(); mode)), '"')
mixin_dep() = if mix == "{}"
nothing
else
script("const $(nameof(Mixin)) = $mix\n")
end
end


Expand Down

0 comments on commit bac3368

Please sign in to comment.