Created
December 12, 2014 20:06
-
-
Save mmwtsn/2bbd01230d365ee44f43 to your computer and use it in GitHub Desktop.
A comparison of `else` placements in a SCSS mixin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bourbon _retina-images.scss via: | |
// https://raw.githubusercontent.com/thoughtbot/bourbon/502c2108dea1970ffeb4f91cb95b545d67bddfd0/app/assets/stylesheets/addons/_retina-image.scss | |
// Current version with @else on a new line | |
@mixin retina-image($filename, $background-size, $extension: png, $retina-filename: null, $retina-suffix: _2x, $asset-pipeline: $asset-pipeline) { | |
@if $asset-pipeline { | |
background-image: image-url("#{$filename}.#{$extension}"); | |
} | |
@else { | |
background-image: url("#{$filename}.#{$extension}"); | |
} | |
@include hidpi { | |
@if $asset-pipeline { | |
@if $retina-filename { | |
background-image: image-url("#{$retina-filename}.#{$extension}"); | |
} | |
@else { | |
background-image: image-url("#{$filename}#{$retina-suffix}.#{$extension}"); | |
} | |
} | |
@else { | |
@if $retina-filename { | |
background-image: url("#{$retina-filename}.#{$extension}"); | |
} | |
@else { | |
background-image: url("#{$filename}#{$retina-suffix}.#{$extension}"); | |
} | |
} | |
background-size: $background-size; | |
} | |
} | |
// Updated version with SCSS Lint `ElsePlacement`, `same_line` setting respected | |
@mixin retina-image($filename, $background-size, $extension: png, $retina-filename: null, $retina-suffix: _2x, $asset-pipeline: $asset-pipeline) { | |
@if $asset-pipeline { | |
background-image: image-url("#{$filename}.#{$extension}"); | |
} @else { | |
background-image: url("#{$filename}.#{$extension}"); | |
} | |
@include hidpi { | |
@if $asset-pipeline { | |
@if $retina-filename { | |
background-image: image-url("#{$retina-filename}.#{$extension}"); | |
} @else { | |
background-image: image-url("#{$filename}#{$retina-suffix}.#{$extension}"); | |
} | |
} @else { | |
@if $retina-filename { | |
background-image: url("#{$retina-filename}.#{$extension}"); | |
} @else { | |
background-image: url("#{$filename}#{$retina-suffix}.#{$extension}"); | |
} | |
} | |
background-size: $background-size; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment