• This repository has been archived on 24/Jan/2021
  • Stars
    star
    228
  • Rank 175,267 (Top 4 %)
  • Language
    JavaScript
  • Created almost 12 years ago
  • Updated about 11 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Don't use it!

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.

More Repositories

1

vim-javascript

Vastly improved Javascript indentation and syntax support in Vim.
Vim Script
3,794
star
2

pacer

My original graph database DSL machine
Ruby
176
star
3

pattern

Pattern lets you transform data structures in amazing ways.
Clojure
116
star
4

pure-conditioning

A simple, fast, purely functional condition / restart system for Clojure.
Clojure
53
star
5

fermor

Fast, powerful, general-purpose graph traversal and modelling tools plus a performant immutable in-memory graph database.
Clojure
43
star
6

ruby_picasa

Provides a super easy to use object layer for authenticating and accessing Picasa through their API.
Ruby
29
star
7

vim-erlang

This repo has been superseded by the one at http://github.com/oscarh/vimerl which is maintained by the original author. Move along, nothing more to see here!
Vim Script
23
star
8

pacer-neo4j

Neo4J adapter for Pacer
Ruby
20
star
9

transducers

Various handy transducers
Clojure
19
star
10

system.check

Test stateful systems using test.check
Clojure
10
star
11

onlisp-in-clojure

Working through the examples in On Lisp, translating them to idiomatic Clojure.
Clojure
9
star
12

objectify_xml

A smart, simple DSL that turns even complex namespaced XML into beautiful Ruby objects.
Ruby
6
star
13

synergize

Extend core and browser Javascript object *instances* with ClojureScript core protocols
Clojure
5
star
14

pacer-bloomfilter

BloomFilter plugin for Pacer
Ruby
5
star
15

genera

Clojure
5
star
16

vim-simplefold

Fork of SimpleFold.vim by Mauricio Fernandez. Space-optimized, configurable code folding for vim.
Vim Script
4
star
17

nested_exceptions

Nested exceptions for all rubies
Ruby
4
star
18

iphone_testify

Help set up an iPhone project for Google toolbox for Mac testing
Objective-C
3
star
19

automatic_resources

Automatically do the right thing with nested resources.
Ruby
3
star
20

pacer-dex

Dex adapter for Pacer
Ruby
3
star
21

pacer-agent

This project has been superseded by pacer-parallel.
Ruby
3
star
22

beehive

Bee Colony Algorithm in Ruby
Ruby
2
star
23

pacer-parallel

Parallelize your Pacer routes
Java
2
star
24

pacer-neo4j-algo

Pacer Neo4J integration to allow Pacer to support all of Neo4j's awesome native features, traversals, etc.
Ruby
2
star
25

vim-sanity

Vim Script
1
star
26

template_parser

Ruby
1
star
27

clj-graph-stream

A general purpose graph traversal library for Clojure
Clojure
1
star