Compile .coffee files to javascript
()
| 185 | |
| 186 | @task |
| 187 | def compile_js(): |
| 188 | """ Compile .coffee files to javascript""" |
| 189 | |
| 190 | root = path("module") / "web" / "media" / "js" |
| 191 | for f in root.glob("*.coffee"): |
| 192 | print "generate", f |
| 193 | coffee = Popen(["coffee", "-cbs"], stdin=open(f, "rb"), stdout=PIPE) |
| 194 | yui = Popen(["yuicompressor", "--type", "js"], stdin=coffee.stdout, stdout=PIPE) |
| 195 | coffee.stdout.close() |
| 196 | content = yui.communicate()[0] |
| 197 | with open(root / f.name.replace(".coffee", ".js"), "wb") as js: |
| 198 | js.write("{% autoescape true %}\n") |
| 199 | js.write(content) |
| 200 | js.write("\n{% endautoescape %}") |
| 201 | |
| 202 | |
| 203 | @task |