Sha256: e95b680aa4a831e1acf66f46c58aab173752cab4b0094b6818db02765d6debd0

Contents?: true

Size: 1007 Bytes

Versions: 1

Compression:

Stored size: 1007 Bytes

Contents

// 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 replace-substring($string, $substring, $new-substring: " ") {
	// 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;
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flint-gs-1.6.5 stylesheets/flint/functions/lib/_replace-substring.scss