Giter VIP home page Giter VIP logo

clang's Introduction

clang

ClojureScript well integrated with the AngularJS framework.

What?

Clang includes an unmodified current release of AngularJS. It allows you to use ClojureScript data structures throughout your angular app and simplifies writing your controllers and directives, etc according to Angular's best practices. Clang integrates ClojureScript into all of Angular's built-in directives.

How?

Clang defines a new $parse provider which is injected throughout Angular and used wherever Angular reads any properties from the scope. It also replaces the Angular $interpolate provider to enable the same thing in {{interpolated}} blocks in your app.

Those two changes enable all of Angular's built in directives to work with ClojureScript except for the ng-repeat which assumes Javascript arrays. Clang's clang-repeat fills that gap.

Show me

Here are a couple of bits of code clipped from the sample index.html

This bit calls the remaining function from the scope and applies the built-in count function to the todos vector:

      <span>{{(remaining)}} of {{(count todos)}} remaining</span>
      [ <a ng-click="(archive)">archive</a> ]

The relevant controller definitions:

(def.controller m TodoCtrl [$scope]
  (assoc! $scope :todos [{:text "learn angular" :done "yes"}
                         {:text "learn cljs" :done "yes"}
                         {:text "build an app" :done "no"}])
  (defn.scope remaining []
    (->>
      (:todos $scope)
      (map :done)
      (remove #{"yes"})
      count)))

Here's a slightly silly but kind of awesome example of building a table:

      <table>
        <tr clang-repeat="group in (drop 1 (partition 3 nums))">
          <td clang-repeat="x in (map (juxt identity odd?) group)">
            {{(first x)}} is {{(if (last x) "odd" "even")}}
          </td>
        </tr>
      </table>

The relevant controller definitions:

(def.controller m TodoCtrl [$scope]
  (assoc! $scope :nums (range 1 10)))

Leiningen Dependency

Clang has not yet been released on clojars, but you can use it as a dependency by checking out the repo and adding a symlink to it under the magic checkouts folder in your project. See this discussion for details.

[clang "0.1.0-SNAPSHOT"]

Try The Sample

lein cljsbuild auto dev
open resources/public/index.html

License

Copyright © 2013 Darrick Wiebe

Distributed under the Eclipse Public License, the same as Clojure.

clang's People

Contributors

amacdougall avatar noprompt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clang's Issues

"clang.todo" and ["clang"] meaning

In:

(def m (module "clang.todo" ["clang"]))

Is it possible to explain what are the semantics of "clang.todo" and ["clang"] in the context of your project sample?

Broken on lein-cljsbuild 0.3.2

Building a project with clang-0.1.0-SNAPSHOT, lein-cljsbuild 0.3.2 and clojurescript-0.0-1803 causes the following error:

$ lein cljsbuild once dev
Compiling ClojureScript.
Compiling "kandan/public/javascripts/bin-debug/main.js" from ["src/cljs"]...
Compiling "kandan/public/javascripts/bin-debug/main.js" failed.
java.lang.NoSuchMethodError: cljs.closure.JavaScriptFile.<init>(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
          closure.clj:278 cljs.closure/javascript-file
          closure.clj:290 cljs.closure/map->javascript-file
          closure.clj:373 cljs.closure/compiled-file
            core.clj:2485 clojure.core/map[fn]
          LazySeq.java:42 clojure.lang.LazySeq.sval
          LazySeq.java:67 clojure.lang.LazySeq.seq
              RT.java:484 clojure.lang.RT.seq
             core.clj:133 clojure.core/seq
             core.clj:678 clojure.core/concat[fn]
          LazySeq.java:42 clojure.lang.LazySeq.sval
          LazySeq.java:60 clojure.lang.LazySeq.seq
             Cons.java:39 clojure.lang.Cons.next
             RT.java:1654 clojure.lang.RT.boundedLength
          RestFn.java:130 clojure.lang.RestFn.applyTo
             core.clj:619 clojure.core/apply
          closure.clj:960 cljs.closure/build
          compiler.clj:57 cljsbuild.compiler/compile-cljs[fn]
          compiler.clj:56 cljsbuild.compiler/compile-cljs
         compiler.clj:140 cljsbuild.compiler/run-compiler
         NO_SOURCE_FILE:1 user/eval2350[fn]
          LazySeq.java:42 clojure.lang.LazySeq.sval
          LazySeq.java:60 clojure.lang.LazySeq.seq
              RT.java:484 clojure.lang.RT.seq
             core.clj:133 clojure.core/seq
            core.clj:2780 clojure.core/dorun
            core.clj:2796 clojure.core/doall
         NO_SOURCE_FILE:1 user/eval2350[fn]
         NO_SOURCE_FILE:1 user/eval2350
       Compiler.java:6619 clojure.lang.Compiler.eval
       Compiler.java:6609 clojure.lang.Compiler.eval
       Compiler.java:6582 clojure.lang.Compiler.eval
            core.clj:2852 clojure.core/eval
             main.clj:308 clojure.main/eval-opt
             main.clj:327 clojure.main/initialize
             main.clj:362 clojure.main/null-opt
             main.clj:440 clojure.main/main
          RestFn.java:421 clojure.lang.RestFn.invoke
             Var.java:419 clojure.lang.Var.invoke
             AFn.java:163 clojure.lang.AFn.applyToHelper
             Var.java:532 clojure.lang.Var.applyTo
             main.java:37 clojure.main.main

Not sure about the source of the problem, will see if we can get this fixed up. In the meantime, putting this here as a heads up for others that you must use lein-cljsbuild 0.3.0 and clojurescript -0.0-1552.

Update to work with Clojure 1.6

Works great in 1.5.1, but I get this error with 1.6:

No protocol method ITransientAssociative.-assoc! defined for type object: [object Object]

Can't run demo

When I run the demo, I get this JS error:

Uncaught TypeError: Cannot set property 'function' of undefined

on this line:

clang.js_types.INamed["function"] = true;

That results in

Uncaught Error: No module: clang.todo

can't require `clang.js-types`

When I require clang.js-types in one of my .cljs file, lein cljsbuild auto gives the following warnings:

WARNING: Use of undeclared Var clang.js-types/INamed at line 28 /Users/xhh/builds/clang/client/clang/js_types.cljs
WARNING: Symbol INamed is not a protocol at line 28 /Users/xhh/builds/clang/client/clang/js_types.cljs
WARNING: Use of undeclared Var clang.js-types/INamed at line 28 /Users/xhh/builds/clang/client/clang/js_types.cljs
WARNING: Use of undeclared Var clang.js-types/-name at line 28 /Users/xhh/builds/clang/client/clang/js_types.cljs

and the web page has the following javascript error

Uncaught TypeError: Cannot set property 'function' of undefined

at the line of the generated javascript:
clang.js_types.INamed["function"] = true;

BTW, I'm using Clojure 1.5.1

Is Clang stable ?

Hello,

I have two questions :

  • Clang is it ready to develop production tools ?
  • When will clang push on Clojar ?

Filters

Filters don't seem to work with clojure data, neither in clang-repeat (where things is a clojure vector)

clang-repeat="thing in things | orderBy:sort"

nor in the controller

(($filter "orderBy") things "propName"

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.