Skip to content

Instantly share code, notes, and snippets.

@kosei27
Created March 5, 2015 03:14
Show Gist options
  • Save kosei27/d305affd06cb4807b34d to your computer and use it in GitHub Desktop.
Save kosei27/d305affd06cb4807b34d to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.12)
// Compass (v1.0.3)
// ----
/*
* Issue with using `inspect()` for a string accidentally
*
* `inspect()`: Return a string containing the value as its Sass representation.
* @url http://sass-lang.com/documentation/Sass/Script/Functions.html#inspect-instance_method
*/
/*
string without quotes
- `quote()` and `unquote()` work properly.
*/
unquoted-string {
$string: foo;
$inspected-string: inspect($string);
result-1: $inspected-string;
$quoted-string: quote($inspected-string);
result-2: $quoted-string;
result-3: unquote($quoted-string);
result-4: #{$quoted-string};
}
/*
quoted string
- `unquote()` doesn't work properly.
*/
quoted-string {
$string: "foo";
$inspected-string: inspect($string);
result-1: $inspected-string;
result-2: quote($inspected-string);
/* can't unquote it! */
result-3: unquote($inspected-string);
result-4: #{$inspected-string};
result-5: unquote( unquote($inspected-string) );
result-6: #{unquote($inspected-string)};
}
/* Use `str-slice()` to remove quotes */
remove-quotes {
$string: "foo";
$inspected-string: inspect($string);
$removed-quotes: str-slice($inspected-string, 2, -2);
result-1: $removed-quotes;
$add-quotes: quote($removed-quotes);
result-2: $add-quotes;
result-3: unquote($add-quotes);
}
/*
* Issue with using `inspect()` for a string accidentally
*
* `inspect()`: Return a string containing the value as its Sass representation.
* @url http://sass-lang.com/documentation/Sass/Script/Functions.html#inspect-instance_method
*/
/*
string without quotes
- `quote()` and `unquote()` work properly.
*/
unquoted-string {
result-1: foo;
result-2: "foo";
result-3: foo;
result-4: foo;
}
/*
quoted string
- `unquote()` doesn't work properly.
*/
quoted-string {
result-1: "foo";
result-2: '"foo"';
/* can't unquote it! */
result-3: "foo";
result-4: "foo";
result-5: "foo";
result-6: "foo";
}
/* Use `str-slice()` to remove quotes */
remove-quotes {
result-1: foo;
result-2: "foo";
result-3: foo;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment