Created
August 26, 2014 07:54
-
-
Save honza/6ceffb2d06a69d20b7f3 to your computer and use it in GitHub Desktop.
Quick wisp macro example - Angular controller
This file contains hidden or 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
| (def app {}) | |
| (defmacro fnj [args & body] | |
| (if (empty? args) | |
| `(fn [] ~@body) | |
| `[~@(map name args) (fn ~args ~@body)])) | |
| (defmacro def-controller [module n args & body] | |
| `(.controller ~module ~(name n) (fnj ~args ~@body))) | |
| (def-controller app Hello [$scope] | |
| (set! $scope.greetings ["hi"]) | |
| nil) |
This file contains hidden or 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 app = exports.app = {}; | |
| app.controller('Hello', [ | |
| '$scope', | |
| function ($scope) { | |
| $scope.greetings = ['hi']; | |
| return void 0; | |
| } | |
| ]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment