From bac3368fe58527a777e4e65d4f67cb326e9d176c Mon Sep 17 00:00:00 2001 From: hhaensel Date: Wed, 29 Nov 2023 22:58:07 +0100 Subject: [PATCH] exclude empty mixins from being included --- src/Stipple.jl | 3 ++- src/stipple/rendering.jl | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Stipple.jl b/src/Stipple.jl index f6f9a138..ab402144 100644 --- a/src/Stipple.jl +++ b/src/Stipple.jl @@ -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 diff --git a/src/stipple/rendering.jl b/src/stipple/rendering.jl index a930e4ac..5fb8b10b 100644 --- a/src/stipple/rendering.jl +++ b/src/stipple/rendering.jl @@ -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