question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sass Function to determine if a string has quotes

See original GitHub issue

There’s currently no way to check if a string has quotes. I suggest we add:

has-quotes($string) => true/false

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:3
  • Comments:18 (7 by maintainers)

github_iconTop GitHub Comments

6reactions
brantwedelcommented, May 31, 2018

I really really needed this, so I wrote a polyfill that uses an interpolation quirk, probably don’t use this, lol.

// @author Brant Wedel
// Check if a string is quoted
// polyfill for str-is-quoted that might be native in sass >= 4.0.0
// Uses concatenation (bug?) in interpolation to test for string quotes
// works in libsass/sass >= v3.4.25
@function str-is-quoted($string) {
    @if type-of($string) != string {
        @error("$string: #{inspect($string)} is not a string for `str-is-quoted'");
    }
    @return "#{$string#{''}}" != $string;
}

https://www.sassmeister.com/gist/b91941959971c3ebeddd9e40f80f8287 https://gist.github.com/brantwedel/b91941959971c3ebeddd9e40f80f8287

3reactions
cimmanoncommented, Nov 12, 2015

@yairEO You don’t need quotes here, you need parentheses.

$typography : (
    font-family    : (Roboto, Arial, sans-serif),
    base-font-size : 14px
);
Read more comments on GitHub >

github_iconTop Results From Across the Web

Strings - Sass
Quoted strings are written between either single or double quotes, as in "Helvetica Neue" . They can contain interpolation, as well as any...
Read more >
SCSS custom function and String extra quotes - Stack Overflow
You can see extra quotes in the compiled css. So i've tried to gsub it with no luck. Why does scss adds these...
Read more >
Sass String Functions - W3Schools
Sass String Functions ; unquote(string), Removes quotes around string (if any), and returns the result. Example: unquote("Hello world!") Result: Hello world!
Read more >
SASS | String Functions - GeeksforGeeks
1. quote($string) Function: This function adds the quotes to the unquoted string and returns the quoted string. Example:.
Read more >
Sass String Functions - TutorialsTeacher
Function Description Examples unquote($string) Removes the quotes, if any, around a string unquote("hello") Result: hello str‑length($string) Returns the number of characters in a string str‑length("hello")...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found