Skip to content

Instantly share code, notes, and snippets.

@kaelig
Last active August 29, 2015 14:11
Show Gist options
  • Save kaelig/72fcec1dd3c37d7a4dff to your computer and use it in GitHub Desktop.
Save kaelig/72fcec1dd3c37d7a4dff to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// libsass (v3.0.2)
// ----
$_o-fonts-families: (
'BentonSans': (
'variants': (
('weight': 'lighter', 'style': 'normal'),
('weight': 'normal', 'style': 'normal'),
('weight': 'bold', 'style': 'normal')
)
),
);
@function _oFontsVariantExists($family, $weight, $style) {
$font-properties: map-get($_o-fonts-families, $family);
$font-variants: map-get($font-properties, variants);
@each $variant in $font-variants {
$variant-weight: map-get($variant, 'weight');
$variant-style: map-get($variant, 'style');
// Check if we find the corresponding weight and style in the map
@if ($variant-weight == $weight and $variant-style == $style) {
@return true;
}
}
@return false;
}
@mixin _oFontsVariantExists($family, $weight, $style) {
$font-properties: map-get($_o-fonts-families, $family);
$font-variants: map-get($font-properties, variants);
@each $variant in $font-variants {
$variant-weight: map-get($variant, 'weight');
$variant-style: map-get($variant, 'style');
// Check if we find the corresponding weight and style in the map
@if ($variant-weight == $weight and $variant-style == $style) {
content: true;
}
}
}
el {
/* With a function, LibSass returns false, for some reason: */
content: _oFontsVariantExists(BentonSans, normal, normal);
/* Using a mixin, LibSass returns true, as expected: */
@include _oFontsVariantExists(BentonSans, normal, normal);
}
el {
/* With a function, LibSass returns false, for some reason: */
content: false;
/* Using a mixin, LibSass returns true, as expected: */
content: true; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment