-1

I wonder if the following syntax is correct for Sass:

@function foo($param)
{
    @return $param;
}
@mixin bar($paramOne, $paramTwo: foo($paramOne))
{
    test: $paramTwo;
}
#test { @include bar(foobar); }

With expected return:

#test { test: foobar; }

Doesn't seems to work (as $paramOne looses it's value) when using the following PHPSASS compiler for SASS/SCSS.

This is the correct syntax? Or I'm missing something?

It's very similar how it's in _vertical_rhythm.scss:

@mixin adjust-font-size-to($to-size, $lines: lines-for-font-size($to-size), $from-size: $base-font-size) {
kenorb
  • 155,785
  • 88
  • 678
  • 743
  • Why are you asking here, rather than keeping it within that issue thread? There is nothing productive about posting it here. If you want to know if it is "correct", then consult the Ruby version http://sassmeister.com/gist/78080cdec3a519c93f2a – cimmanon Nov 11 '14 at 13:48
  • @cimmanon I'm asking about the correct syntax of Sass stylesheet language as I'm not familiar with Sass. Should I post to [codereview](http://codereview.stackexchange.com/) instead? I think you answered already that it is correct and you can use arguments within the function. – kenorb Nov 11 '14 at 13:54

1 Answers1

0

It seems that kind of syntax is completely valid as cimmanon posted it on sassmeister gist (thanks) which is using Ruby version of parser. Some other parsers could have problem with that (phpsass in that case) depending how they implemented that logic.

In case of issues, make sure that you're using the right parser for scss syntax, not sass syntax (wiki, e.g. new SassParser(['syntax' => 'scss'])). See: What's the difference between SCSS and Sass?


Note that the same syntax was used in Compass (open-source CSS Authoring Framework) for Vertical Rhythm as:

@mixin adjust-font-size-to($to-size, $lines: lines-for-font-size($to-size), $from-size: $base-font-size)

but in the recent version it's just:

@mixin adjust-font-size-to($to-size, $lines: auto, $from-size: $base-font-size)
Community
  • 1
  • 1
kenorb
  • 155,785
  • 88
  • 678
  • 743