stylesheets/flint/functions/lib/_replace-substring.scss in flint-gs-1.7.1 vs stylesheets/flint/functions/lib/_replace-substring.scss in flint-gs-1.7.2

- old
+ new

@@ -1,34 +1,34 @@ -// Replace substring -// ------------------------------------------------------------------------------- -// @param $string [string] : string that contains substring -// @param $substring [string] : substring to replace -// @param $new-substring [string] : new string to replace sub with -// ------------------------------------------------------------------------------- -// @return [string] - -@function flint-replace-substring($string, $substring, $new-substring: " ") { - - // Use Ruby function if available - @if $flint__use-ruby-functions { - @return replace_substring($string, $substring, $new-substring); - } @else { - // Loop through length of string - @for $i from 1 through str-length($string) { - // Get index and length of substring - $sub-index: str-index($string, $substring); - $sub-length: str-length($substring); - - // If count is index of substring - @if $i == $sub-index { - // Slice string to exclude substring - $string-before: str-slice($string, 1, $i - 1); - $string-after: str-slice($string, $i + $sub-length, str-length($string)); - // Create new string - $string: $string-before + $new-substring + $string-after; - } - - } - - @return $string; - } -} +// Replace substring +// ------------------------------------------------------------------------------- +// @param $string [string] : string that contains substring +// @param $substring [string] : substring to replace +// @param $new-substring [string] : new string to replace sub with +// ------------------------------------------------------------------------------- +// @return [string] + +@function flint-replace-substring($string, $substring, $new-substring: " ") { + + // Use Ruby function if available + @if $flint__use-ruby-functions { + @return replace_substring($string, $substring, $new-substring); + } @else { + // Loop through length of string + @for $i from 1 through str-length($string) { + // Get index and length of substring + $sub-index: str-index($string, $substring); + $sub-length: str-length($substring); + + // If count is index of substring + @if $i == $sub-index { + // Slice string to exclude substring + $string-before: str-slice($string, 1, $i - 1); + $string-after: str-slice($string, $i + $sub-length, str-length($string)); + // Create new string + $string: $string-before + $new-substring + $string-after; + } + + } + + @return $string; + } +}