aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick H. Lauke <[email protected]>2016-10-20 18:14:56 +0100
committerPatrick H. Lauke <[email protected]>2016-10-20 18:26:36 +0100
commitb2fe9743ccae0c260ba79629b7516b5bb21adcda (patch)
tree2a42ffd1bc25ab5889c9a7359148d73eea68748e
parentb5890e0608ad2262cde4a38e90afa19f1cb5d852 (diff)
downloadbootstrap-b2fe9743ccae0c260ba79629b7516b5bb21adcda.tar.xz
bootstrap-b2fe9743ccae0c260ba79629b7516b5bb21adcda.zip
Add str-replace Sass function
-rw-r--r--scss/_variables.scss16
1 files changed, 16 insertions, 0 deletions
diff --git a/scss/_variables.scss b/scss/_variables.scss
index 13432f2f3..e6cd6a333 100644
--- a/scss/_variables.scss
+++ b/scss/_variables.scss
@@ -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.