Skip to content

Instantly share code, notes, and snippets.

@Cartmanishere
Created February 14, 2021 12:36
Show Gist options
  • Save Cartmanishere/b199a92256a2a1c649f3e0a203d621d0 to your computer and use it in GitHub Desktop.
Save Cartmanishere/b199a92256a2a1c649f3e0a203d621d0 to your computer and use it in GitHub Desktop.
;; Util to convert Clojure map to Java Hashmap
(defn clj-map->java-map
[data]
(postwalk
#(cond
(map? %) (java.util.HashMap. ^java.util.Map %)
(keyword? %) (name %)
:else %)
data))
;; Initialize the http loader
(def loader (http-loader "https://bucket-name.s3.Region.amazonaws.com/"))
;; Initialize the Handlebars object with custom loader
(def hbs (Handlebars. loader))
;; Render a `index.hbs` file with some data
(-> (.compile hbs "index")
(.apply (clj-map->java-map {:title "This is title"})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment