Skip to content

Instantly share code, notes, and snippets.

@Cartmanishere
Created July 23, 2021 12:51
Show Gist options
  • Save Cartmanishere/9193b9d3b903c5e650a9a6af8c014207 to your computer and use it in GitHub Desktop.
Save Cartmanishere/9193b9d3b903c5e650a9a6af8c014207 to your computer and use it in GitHub Desktop.
(ns clj-handlebars.http-loader
(:gen-class
:init init
:state state
:name com.github.jknack.handlebars.io.HTTPCljLoader
:implements [com.github.jknack.handlebars.io.TemplateLoader]
:constructors {[String] []}
:prefix "-")
(:import [com.github.jknack.handlebars.io URLTemplateSource]
[java.net URL]))
(defn -init
[^String baseUrl]
[[] {:prefix baseUrl
:suffix ".hbs"}])
(defn -resolve
[this filename]
(str (. this getPrefix) filename (. this getSuffix)))
(defn -getPrefix
[this]
(str (:prefix (.state this))))
(defn -getSuffix
[this]
(str (:suffix (.state this))))
(defn -sourceAt
[this uri]
(let [location (. this resolve uri)]
(URLTemplateSource. location (URL. location))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment