Created
January 16, 2013 21:08
-
-
Save acdha/4550977 to your computer and use it in GitHub Desktop.
Bulk-convert CSS to SASS SCSS using css2sass, curl and xmlstarlet
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
#!/bin/bash | |
for f in *.css; do | |
echo $f ${f/.css/.scss}; | |
curl -s -X POST http://css2sass.heroku.com/xml --data-urlencode "page[css]@$f" -d commit="Convert 2 SCSS" | xmlstarlet sel -t -v /page/sass | xmlstarlet unesc > ${f/.css/.scss}; | |
done |
This doesn't seem to work anymore. The html isn't well formed which breaks xmlstarlet and it uses a different URL. Here is a modified version that works with pearl instead of xmlstarlet. If you want scss change all the sass parts to scss.
#!/bin/bash
for f in *.css; do
echo $f ${f/.css/.sass};
curl -s -X POST http://css2sass.herokuapp.com --data-urlencode "page[css]@$f" -d commit="Convert 2 SASS" | sed -n "s:.*<textarea id='page_sass' name='page\[sass\]'>\(.*\)</textarea>.*:\1:p" | perl -MHTML::Entities -pe 'decode_entities($_);' > ${f/.css/.sass};
done
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
only for info: there is also a command for this ->
sass-convert --from css --to sass foo.css bar.sass