From 894a7022453797f939a67a36411ecd5d76d5f3e0 Mon Sep 17 00:00:00 2001 From: alpadev Date: Thu, 2 Jan 2014 22:18:41 +0100 Subject: [PATCH] adds: stylus generator --- tasks/sprites.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tasks/sprites.js b/tasks/sprites.js index 95a35be..d83dbe1 100644 --- a/tasks/sprites.js +++ b/tasks/sprites.js @@ -96,6 +96,17 @@ module.exports = function(grunt) { return fileContents; } + function generateStylusFile (imageData, images, placeholder) { + var fileContents = ''; + + fileContents += '$' + placeholder + '\n background: url("' + generateBackgroundImagePath() + '") no-repeat\n\n'; + imageData.heights.forEach(function (height, idx) { + fileContents += '$' + (classPrefix === '' ? '' : classPrefix + '-') + path.basename(images[idx].file, '.png') + '\n @extend $' + placeholder + '\n background-position: 0 ' + ( height > 0 ? -height + 'px' : 0 ) + '\n\n'; + }); + + return fileContents; + } + function runSpriteGenerator (images) { // spawn a phantom js process var ps = spawn(binPath, ['--web-security=no', path.resolve(__dirname, '../lib/phantomspriter.js')]); @@ -150,6 +161,9 @@ module.exports = function(grunt) { case "less": stylesData = generateLESSFile(incomingData, images, placeHolder); break; + case "stylus": + stylesData = generateStylusFile(incomingData, images, placeHolder); + break; default: stylesData = generateCSSFile(incomingData, images); break;