retrogradeorbit / bootleg

Simple template processing command line tool to help build static websites
Eclipse Public License 2.0
254 stars 12 forks source link

read from stdin #44

Closed borkdude closed 4 years ago

borkdude commented 4 years ago
./bootleg -d <<< '<html></html>'
retrogradeorbit commented 4 years ago

notes: keep default in format as clj hiccup. Expose stdin as stream *in* for other conversions like html input here. something like bootleg -d -e '(convert-to *in* :hiccup)' <<< '<html></html>'

retrogradeorbit commented 4 years ago

Reads script from stdin when no file is passed in and no -e flag

$ bootleg <<< '[:p 1]'
<p>1</p>

*in* is bound to clojure.lang.LineNumberingPushbackReader on stdin as it is in clojure. So you need to slurp it:

echo -n "<html></html>" | bootleg -d -e '(-> *in* slurp (convert-to :hiccup))'
[:html {}]

Need to be careful of trailing newlines in <<< pipe.

$ bootleg -d -e '(-> *in* slurp (convert-to :hiccup))' <<< '<html></html>'
"\n"
$ bootleg  -d -e '(-> *in* slurp (convert-to :hiccup-seq))' <<< '<html></html>'
([:html {}] "\n")

new related issue: https://github.com/retrogradeorbit/bootleg/issues/53