Working toward varref psths in generation.

This commit is contained in:
John Wiseman 2019-12-18 09:21:51 -08:00
parent 3ab099d9ef
commit 0f9dddacee
3 changed files with 20 additions and 1 deletions

View File

@ -47,6 +47,14 @@
(defmulti expand% (fn [template data] (first template))) (defmulti expand% (fn [template data] (first template)))
;; (defmethod expand% :varref [template data]
;; (let [var (keyword (second template))
;; var-path (string/split var #"\.")
;; val (get-in data var-path)]
;; (if (or (nil? val) (= val ""))
;; '()
;; (list {:varrefs [var] :text (str (data var))}))))
(defmethod expand% :varref [template data] (defmethod expand% :varref [template data]
(let [var (keyword (second template)) (let [var (keyword (second template))
val (data var)] val (data var)]

View File

@ -11,7 +11,7 @@
(logging/deflog "pelias" logger) (logging/deflog "pelias" logger)
(def base-pelias-url "http://raytheon.local:4000/v1") (def base-pelias-url "http://lockheed.local:4000/v1")
;; Does an HTTP GET to a pelias API url. Returns a promise that ;; Does an HTTP GET to a pelias API url. Returns a promise that

View File

@ -64,3 +64,14 @@
:country "Country"} :country "Country"}
{:neighborhood 5 {:neighborhood 5
:locality 2}))))) :locality 2})))))
(deftest var-paths
(is (= "Hello, John"
(generation/generate
[(generation/parse-template "Hello, {person.name}")]
{:person {:name "John"}})))
(is (= 9
(generation/generate
[(generation/parse-template "Hello, {person.name}")]
{:person {:age 49}}))))