Skip to content

taojoe/clj-template-literal

Repository files navigation

clj-template-literal

clojure template literals as javascript. the idea is from MDN Template literals

Usage

Template literals is the best way to do safe sql, it's more than that. the best usage please see the a similar library in javascript SQL Template Strings

Please see the test file to know how to do it.

(let [name "joe"] 
  (= (<<< str "hello from ~{name}, do math ~(+ 1 2)") "hello from joe, do math 3"))

(= (<<< sql "select * from user where name=~{name}") ["select * from user where name= ? " name])

Thanks

The idea is from clojure.core.strint, it is best for clojure doing the interpolate thing.

This library just make it work with user defined function other than str.

Releases

No releases published

Packages

No packages published