Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/jai version 0.2.7 Aug 14, 2015
test/jai migration to hara.test Sep 3, 2016
.gitignore finished documentation May 23, 2015
.gitmodules v0.2.9 Jan 18, 2016
.travis.yml migration to hara.test Sep 3, 2016
README.md v0.2.12 Sep 13, 2016
project.clj v0.2.12 Sep 13, 2016

README.md

jai

Build Status

Installation

Add to project.clj dependencies:

[im.chit/jai "0.2.12"]

All functionality is in the jai.query namespace:

> (use jai.query)

Manipulate source code like the DOM

Introduction

jai makes it easy for querying and manipulation of clojure source code through an xpath/css-inspired syntax.

  • to simplify traversal and manipulation of source code
  • to provide higher level abstractions on top of rewrite-clj
  • to leverage core.match's pattern matching

A blog post that tells a little bit more about it.

Motivation

As lisp code follows a tree-like structure, it is very useful to be able to have a simple language to be able to query as well as update elements of that tree. The best tool for source code manipulation is rewrite-clj. However, it is hard to reason about the higher level concepts of code when using just a zipper for traversal.

jai is essentially a query/manipulation tool inspired by jquery and css selectors that make for easy dom manipulation and query. Instead of writing the following code with rewrite-clj:

(if (and (-> zloc z/prev z/prev z/sexpr (= "defn"))
         (-> zloc z/prev z/sexpr vector?)
    (do-something zloc)
    zloc)

jai allows the same logic to be written in a much more expressive manner:

($ zloc [(defn ^:% vector? | _)] do-something)

Documentation

Please see the main documentation for usage and examples.

License

Copyright © 2015 Chris Zheng

Distributed under the MIT License