-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from retrogradeorbit/issue-24-refactor-path-ca…
…pture-to-use-context-thread-local use thread local context/*path* for file path
- Loading branch information
Showing
8 changed files
with
71 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
(ns bootleg.edn | ||
(:require [bootleg.file :as file] | ||
[bootleg.context :as context] | ||
[clojure.edn :as edn])) | ||
|
||
(defn load-edn [path file] | ||
(-> (file/path-join path file) slurp edn/read-string)) | ||
(defn load-edn | ||
([file] (load-edn context/*path* file)) | ||
([path file] | ||
(-> (file/path-join path file) slurp edn/read-string))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
(ns bootleg.html | ||
(:require [bootleg.file :as file] | ||
[bootleg.utils :as utils])) | ||
[bootleg.utils :as utils] | ||
[clojure.java.io :as io])) | ||
|
||
(defn make-html-fn [path] | ||
(fn html [source & options] | ||
(let [flags (into #{} options) | ||
markup (if (:data flags) | ||
source | ||
(slurp (file/input-stream path source)))] | ||
(utils/html-output-to flags markup)))) | ||
(defn html [source & options] | ||
(let [flags (into #{} options) | ||
markup (if (:data flags) | ||
source | ||
(slurp (io/input-stream (file/path-relative source))))] | ||
(utils/html-output-to flags markup))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
(ns bootleg.json | ||
(:require [bootleg.file :as file] | ||
[bootleg.context :as context] | ||
[clojure.data.json :as json])) | ||
|
||
(defn load-json [path file] | ||
(-> (file/path-join path file) | ||
slurp | ||
(json/read-str :key-fn keyword))) | ||
(defn load-json | ||
([file] (load-json context/*path* file)) | ||
([path file] | ||
(-> (file/path-join path file) | ||
slurp | ||
(json/read-str :key-fn keyword)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
(ns bootleg.markdown | ||
(:require [bootleg.file :as file] | ||
[bootleg.utils :as utils] | ||
[markdown.core :as markdown])) | ||
[markdown.core :as markdown] | ||
[clojure.java.io :as io])) | ||
|
||
(defn make-markdown-fn [path] | ||
(fn markdown [source & options] | ||
(let [flags (into #{} options) | ||
markup (if (:data flags) | ||
(markdown/md-to-html-string source) | ||
(let [body (java.io.ByteArrayOutputStream.)] | ||
(markdown/md-to-html (file/input-stream path source) body) | ||
(.toString body)))] | ||
(utils/html-output-to flags markup)))) | ||
(defn markdown [source & options] | ||
(let [flags (into #{} options) | ||
markup (if (:data flags) | ||
(markdown/md-to-html-string source) | ||
(let [body (java.io.ByteArrayOutputStream.)] | ||
(markdown/md-to-html (io/input-stream (file/path-relative source)) body) | ||
(.toString body)))] | ||
(utils/html-output-to flags markup))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
(ns bootleg.mustache | ||
(:require [bootleg.file :as file] | ||
[bootleg.utils :as utils] | ||
[cljstache.core :as mustache])) | ||
[cljstache.core :as mustache] | ||
[clojure.java.io :as io])) | ||
|
||
(defn make-mustache-fn [path] | ||
(fn mustache [source vars & options] | ||
(let [flags (into #{} options) | ||
pre-markup (if (:data flags) | ||
source | ||
(slurp (file/input-stream path source))) | ||
markup (mustache/render pre-markup vars)] | ||
(utils/html-output-to flags markup)))) | ||
(defn mustache [source vars & options] | ||
(let [flags (into #{} options) | ||
pre-markup (if (:data flags) | ||
source | ||
(slurp (io/input-stream (file/path-relative source)))) | ||
markup (mustache/render pre-markup vars)] | ||
(utils/html-output-to flags markup))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
(ns bootleg.yaml | ||
(:require [bootleg.file :as file] | ||
[bootleg.context :as context] | ||
[yaml.core :as yaml])) | ||
|
||
(defn load-yaml [path file] | ||
(-> (file/path-join path file) | ||
slurp | ||
(yaml/parse-string :keywords true))) | ||
(defn load-yaml | ||
([file] (load-yaml context/*path* file)) | ||
([path file] | ||
(-> (file/path-join path file) | ||
slurp | ||
(yaml/parse-string :keywords true)))) |