diff --git a/lib/phlex/variants.rb b/lib/phlex/variants.rb index cb32420..16f58fc 100644 --- a/lib/phlex/variants.rb +++ b/lib/phlex/variants.rb @@ -37,6 +37,9 @@ def build_variants_style(variants) value = options[option] next value if value + + # doesn't raise error when passing false for variant with only true/:yes option + next if option == false && options.has_key?(true) end raise_variant_not_found_error(options, variant, option) diff --git a/spec/phlex/variants_spec.rb b/spec/phlex/variants_spec.rb index 0b4d9c8..78e78f4 100644 --- a/spec/phlex/variants_spec.rb +++ b/spec/phlex/variants_spec.rb @@ -199,6 +199,20 @@ def view_template expect(example.build_style(loading: :yes, full: :no)).to eq "btn-loading btn-fit" end + it "doesn't raise error when passing false for a variant with only true/:yes options" do + example = phlex_class do + style do + variants do + outline do + yes "btn-outline" + end + end + end + end + + expect(example.build_style(outline: false)).to eq "" + end + it "ignores nil variants" do example = phlex_class do style do