String functions
Sass has some built-in functions to manipulate strings. In this recipe, you will learn about the quote()
and unquote()
functions. These functions add or remove surrounding quotes from a string value.
Getting ready
Read the Installing Sass for command line usage recipe of Chapter 1, Getting Started with Sass, to install Ruby Sass. After this, you can also use Sass interactive to evaluate the results of the string functions, as described in the Using Sass interactive mode and SassScript recipe of Chapter 1, Getting Started with Sass.
How to do it...
The following are the steps for implementing string function:
Create a Sass template called
main.scss
. This template should contain the SCSS code like the following:// scss-lint:disable DuplicateProperty .test { color: hsla(0, 100%, 50%, 1); //fall-back color: unquote('hsla(0, 100%, 50%, 1)'); }
Compile the SCSS file from the previous step by running the following command in your console:
sass main.scss
Finally, you will find...