Created
June 9, 2009 13:45
-
-
Save nijitaro/126494 to your computer and use it in GitHub Desktop.
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
hello :) |
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
var SASS = { | |
parse: function (source) { | |
source = source.replace( /\r|\r\n/g, "\n"); | |
var lines = source.split("\n"); | |
var _level = 0; | |
var retVal = "$(document)"; | |
$(lines).each(function(){ | |
var line = this.toString(); | |
var arr = line.match( /^\s+/ ); | |
if(arr == null || !/\S+/.test(line)) { | |
return; | |
} | |
var lvl = arr[0].length / 2; | |
var order = line.replace(/^\s*/, ""); | |
if(_level > lvl) { | |
for (var i = 0; i < _level - lvl; i++) retVal += ".end()"; | |
} | |
_level = lvl; | |
if(/^:/.test(order)){ | |
var arr = order.match(/:(\S+)\s+(.*)/); | |
retVal += ".css('"+ arr[1] + "','" + arr[2] +"')"; | |
}else{ | |
retVal += ".find('"+ order +"')"; | |
} | |
}); | |
retVal += ";"; | |
//console.log(retVal); | |
return retVal; | |
} | |
} | |
$(function(){ | |
$("script[type='text/sass']").each(function(){ | |
eval(SASS.parse(this.innerHTML)); | |
}); | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
test