Giter Club home page Giter Club logo

gyr's Introduction

gyr

Build Status

A nicer angularjs interop for clojurescript

Usage

Stable Version:

[im.chit/gyr "0.3.1"] 

Documentation:

Angular Simplified

As much as I became amazed at the possibilities of angularjs, I was also experiencing alot of pain when developing with javascript. Javascript is not the best language to work with and unless one is serious javascript expert (which I am far from), it was very easy to complect modules within large angular.js applications. Using coffeescript did not solve the problem and in fact, made things worse with its white-space indentation style.

I also found that properly architected angular.js applications had WAY too many files for my liking - as seen in the Year of Moo projects. I wanted to use clojure syntax so that my code was smaller, more readable and easier to handle. Essentially, I believe that great angular apps should be able to be written in one file.

Gyr currently offers:

  • gyr.core - a simple dsl for eliminating boilerplate angular.js
  • gyr.test - testing macros for eliminating more boilerplate test code for services, controllers, directives and filters
  • gyr.filters - undocumented library of clojure-style filters for angular.js
Angular JS
;; purnam.angular

(def.module my.app [])

(def.config my.app [$routeProvider]
  (-> $routeProvider
      (.when "/" (obj :templateUrl "views/main.html"))
      (.otherwise (obj :redirectTo "/"))))

(def.controller my.app.MainCtrl [$scope $http]
  (! $scope.msg "")
  (! $scope.setMessage (fn [msg] (! $scope.msg msg)))
  (! $scope.loginQuery
     (fn [user pass]
       (let [q (obj :user user
                    :pass pass)]
         (-> $http
             (.post "/login" q)
             (.success (fn [res]
                         (if (= res "true")
                           (! $scope.loginSuccess true)
                           (! $scope.loginSuccess false))))
             (.error (fn [] (js/console.log "error!!")))))))
AngularJS Testing
;; purnam.test.angular

(describe.controller
 {:doc "A sample controller for testing purposes"
  :module my.app
  :controller MainCtrl}

 (it "should be able to change the message within the $scope"
  (is $scope.msg "Hello") 
  (do ($scope.setMessage "World!")
      (is $scope.msg "World!"))

  (do ($scope.setMessage "Angular Rocks!")
      (is $scope.msg "Angular Rocks!"))))

License

Copyright © 2014 Chris Zheng

Distributed under the The MIT License.

gyr's People

Watchers

James Cloos avatar Roma Chi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.