Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

About

moved -> 'lucid.query'

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published