]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Add str-replace Sass function
authorPatrick H. Lauke <redux@splintered.co.uk>
Thu, 20 Oct 2016 17:14:56 +0000 (18:14 +0100)
committerPatrick H. Lauke <redux@splintered.co.uk>
Thu, 20 Oct 2016 17:26:36 +0000 (18:26 +0100)
scss/_variables.scss

index 13432f2f3c135741edc9a130d4f91a69a2f331f8..e6cd6a3332e421588977b39fd6a54f586a307c4a 100644 (file)
   }
 }
 
+/// 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.