Created
January 11, 2012 05:15
-
-
Save ggoodman/1593167 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
compile = (fn) -> | |
fnText = fn.toString() | |
fnArgs = fnText.substring(fnText.indexOf("(") + 1, fnText.indexOf(")")).replace(/^\s+|\s+$/g, "").split(",") | |
fnBody = fnText.substring(fnText.indexOf("{") + 1, fnText.lastIndexOf("}")) | |
code = "with(context) { with (window.drykup()) {" | |
for arg, i in fnArgs | |
unless arg.replace(/^\s+|\s+$/g, "") is "" | |
code += "var #{arg} = arguments[#{i}];\n" | |
code += fnBody | |
code += "}}" | |
alert code.replace(/return/g, "") | |
(context = {}) -> | |
eval code.replace(/return/g, "") | |
tpl = compile -> | |
div class: name, -> | |
a name | |
span "ba" | |
alert tpl(name: "ggoodman") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment