I have a value in the surrounding Clojure context in some local variable x
that I want to use inside the meander program. I think the idiom is to pass in x
using something like (m/rewrite {:x x, :rewrite-data ...}
. Sometimes, it's inconvenient to use this idiom because it gets reflected in most / all of the rewrite rules. Is there another way to pull x
from the Clojure context into meander? There may be a way to abuse m/app
but is there a nicer way?
You can use unquote.
(let [x 2]
(m/rewrite {:x 2 :y 3}
{:x ~x :y ?y}
{:y ?y}))
;; =>
{:y 3}
great. thanks!
for future reference, rtfm: https://github.com/noprompt/meander/blob/0b8d285d735d58ec9db3bbbe2455b5f3628e30f3/doc/operator-overview.md#unquote
Haha, yeah there is a lot going on it is easy to miss.