Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMaxim Lebid
18,294 PointsModular CSS with Sass code, Challenge task 1 of 1
Use a Sass introspection function to import the URL value of the $font-url variable, if it exists in the current scope.
this is my code:
@if varible-exists(font-url) { @import url(font-url); }
And eror: Bummer! You need to call the variable-exists function.
Can someone suggest what is wrong in my code ?
9 Answers
Thien Nguyen
20,555 Points@if variable-exists(font-url) { @import url($font-url); }
CORRECT
Nicholas Mejia
23,800 PointsYou misspelled variable in your if statement :)
Maxim Lebid
18,294 PointsThanks:)
Luis Chiappe
Courses Plus Student 10,636 PointsI know what already is happening.
The parameter of variable-exists, should not have "$", but inside the function when you import the URL yes you need put the "$".
Let me know if working.
Thien Nguyen
20,555 Points@if variable-exists(font-url--google) { @import url($font-url--google); }
CORRECT
thank you!
Luis Chiappe
Courses Plus Student 10,636 PointsJust you forget the $ on the variable inside the "url"; @if varible-exists(font-url) { @import url($font-url); }
Maxim Lebid
18,294 PointsThanks:)
Thien Nguyen
20,555 PointsI used this and still get it wrong
@if variable-exists($font-url)
{ @import url($font-url); }
I got this error
Sass Error: Undefined variable: "$font-url".
Luis Chiappe
Courses Plus Student 10,636 Pointsyou set the variable in another file?
$font-url: 'http://fonts.googleapis.com/css?family=Roboto';
Thien Nguyen
20,555 PointsThey only give us 1 file. style.scss
putting this I got the same error.
$font-url: 'http://fonts.googleapis.com/css?family=Roboto';
@if variable-exists($font-url) { @import url($font-url); }
Luis Chiappe
Courses Plus Student 10,636 PointsTry with this:
$font-url--google : 'http://fonts.googleapis.com/css?family=Roboto:400,100,300,100italic,300italic,400italic,500,500italic,700,700italic,900,900italic';
@if variable-exists(font-url--google) { @import url($font-url--google); }
Thien Nguyen
20,555 PointsThat is the same code from the workspace. I tried and even remove the --google
but still did not work.
Luis Chiappe
Courses Plus Student 10,636 PointsYes, but maybe with declare options in the font helps.
Can you say me what the error said?
Thien Nguyen
20,555 PointsYou need to call the variable-exists function, passing the name of the font-url variable as a parameter.
Luis Chiappe
Courses Plus Student 10,636 PointsGreat! :)