kodie
11/3/2016 - 1:51 PM

An SCSS function that returns true if $string ends with $find, and false if it doesn't.

An SCSS function that returns true if $string ends with $find, and false if it doesn't.

@function ends-with($string, $find) {
  @if (str-slice($string, (str-length($string) - str-length($find) + 1)) == $find) {
    @return true;
  } @else {
    @return false;
  }
}

$font-icons: (
  'facebook': '\e614',
  'facebook-outline': '\e615',
  'twitter': '\e616',
  'twitter-outline': '\e617',
  'instagram': '\e618',
  'instagram-outline': '\e619'
);

@each $name, $char in $font-icons {
  .module-#{$name}:before {
    content: $char;
    
    @if (ends-with($name, '-outline')) {
      border: 1px solid #000;
      border-radius: 50%;
    }
  }
}