Skip to content

Instantly share code, notes, and snippets.

@a2
Created February 13, 2016 12:05
Show Gist options
  • Select an option

  • Save a2/ce79263aac14ba514bd1 to your computer and use it in GitHub Desktop.

Select an option

Save a2/ce79263aac14ba514bd1 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
@function at2x-name($filename) {
$length: str-length($filename);
@if $length == 0 {
// return empty if input is empty
@return $filename;
}
@for $i from str-length($filename) through 1 {
$slice: str-slice($filename, $i, $i);
@if $slice == "." {
@return str-insert($filename, "@2x", $i);
}
}
@return $filename + "@2x";
}
.test {
content: at2x-name("");
content: at2x-name("test");
content: at2x-name("test.png");
content: at2x-name("test.abc.png");
}
.test {
content: "";
content: "test@2x";
content: "[email protected]";
content: "[email protected]";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment