0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-02-19 16:54:24 +01:00

Add str-replace Sass function

This commit is contained in:
Patrick H. Lauke 2016-10-20 18:14:56 +01:00
parent b5890e0608
commit b2fe9743cc

View File

@ -33,6 +33,22 @@
}
}
/// Replace `$search` with `$replace` in `$string`
/// @author Hugo Giraudel
/// @param {String} $string - Initial string
/// @param {String} $search - Substring to replace
/// @param {String} $replace ('') - New value
/// @return {String} - Updated string
@function str-replace($string, $search, $replace: "") {
$index: str-index($string, $search);
@if $index {
@return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
}
@return $string;
}
// General variable structure
//
// Variable format should follow the `$component-modifier-state-property` order.