Skip to content

Instantly share code, notes, and snippets.

@honza
Created August 26, 2014 07:54
Show Gist options
  • Select an option

  • Save honza/6ceffb2d06a69d20b7f3 to your computer and use it in GitHub Desktop.

Select an option

Save honza/6ceffb2d06a69d20b7f3 to your computer and use it in GitHub Desktop.
Quick wisp macro example - Angular controller
(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)
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