Created
August 28, 2015 09:04
-
-
Save KittyGiraudel/3e24a29ae48c7a61b12e to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// Sass (v3.4.14) | |
// Compass (v1.0.3) | |
// ---- | |
@function replace-attr($message) { | |
$has-attr: str-index($message, 'attr('); | |
$first-paren: str-index($message, ')'); | |
@if not $has-attr { | |
@return $message; | |
} | |
$first-chunk: str-slice($message, 1, $has-attr - 1); | |
$last-chunk: str-slice($message, $first-paren + 1); | |
$result: (); | |
@if str-length($first-chunk) > 0 { | |
$result: append($result, $first-chunk); | |
} | |
$result: append($result, unquote(str-slice($message, $has-attr, $first-paren))); | |
@if str-length($last-chunk) > 0 { | |
$result: append($result, replace-attr($last-chunk)); | |
} | |
@return $result; | |
} | |
.foo { | |
content: replace-attr('attr(foo) hello ba attr(bar) attr(baz) foo attr(qux)'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.foo { | |
content: attr(foo) " hello ba " attr(bar) " " attr(baz) " foo " attr(qux); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment