Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.2)
// Compass (v1.0.0.alpha.17)
// ----
// Simple String Substitute
//
@function sub($string, $replace, $value) {
$replace-len: str-length($replace);
$replace-start: str-index($string, $replace);
$string-len: str-length($string);
$string-left: str-slice($string, 1, $replace-start - 1);
$string-right: str-slice($string, $replace-start + $replace-len);
@return #{$string-left}#{$value}#{$string-right};
}
// Template Parser
//
@function parse-template($template, $value) {
@return sub($template, 'VALUE', $value);
}
.debug {
foo: parse-template('.box.VALUE', 'clouds');
}
.debug {
foo: .box.clouds;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.