Created
April 17, 2013 06:28
-
-
Save hammady/5402193 to your computer and use it in GitHub Desktop.
BASH script to convert image urls in .CSS files to .ERB style asset paths.
Example usage:
./erbify-css.sh src libfoo input-file.css
converts:
.showgrid { background: url(src/grid.png); }
to:
.showgrid { background: url(<%=asset_path("libfoo/grid.png")%>); }
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 | |
if [ $# -ne 3 ]; then | |
echo "Usage: $0 <substitute-path> <with-path> <css-file>" | |
exit 1 | |
fi | |
from=$1 | |
to=$2 | |
file=$3 | |
out=$file.erb | |
sed 's{url\s*(\s*'$from'\([^)]\+\){url(<%=asset_path("'$to'\1")%>{g' $file > $out | |
echo $out written |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment