Fork me on GitHub
#beginners
<
2016-05-25
>
mikepjb12:05:59

@bojan.matic: @bwstearns I think chestnut does what we want

mikepjb12:05:04

lein new chestnut test-clj-stack -- --reagent

mikepjb12:05:23

that will setup a ring/clojure server with cljs reagent

mikepjb12:05:35

leave out the -- --reagent if you want om which is the default

sveri13:05:23

@bojan.matic: closp delivers that: https://github.com/sveri/closp plus a lot of more stuff that you might / might not need

bojan.matic13:05:07

so, a question that I think was already asked here, comes to my mind: is there a way to explore all the available lein templates?

sveri13:05:25

http://www.clojure-toolbox.com/ has not all, but I think the most popular should be there

sveri13:05:43

Although it is not only templates, but templates / libraries in general

bojan.matic13:05:00

so there is no way to see all the available templates? how does lein look for them then?

sveri13:05:04

I did not say there is none, thats just what I am looking for. I dont know how leiningen looks for them, hopefully someone else does 🙂

bojan.matic13:05:37

sorry, you might have read that in the wrong tone (damn text-based communication) 🙂

sveri13:05:42

Yea, no problem, nothing happened here 🙂

surreal.analysis13:05:56

That should give you (I think) all of them

surreal.analysis13:05:13

You could also run lein search lein-template from the command line

mattsfrey21:05:34

is it possible to write a macro that return multiple key value pairs ”in place", rather than returning a map?

seancorfield21:05:30

As I said in #C03S1KBA2 (repeated here for the benefit of others): Why not just use a function? (pad-fn "25px" {:color "blue"}) — macros don’t compose so functions are nearly always preferable.

seancorfield21:05:35

Although a lot of people think about "the power of Lisp" being about macros, in reality macros aren’t used as much as you might think, and even those that are used tend to have a function underneath that does the heavy lifting.

seancorfield21:05:22

Using a function here would allow for composition with similar functions that added style attributes: (def margin-and-padding (comp (partial margin-fn "5px") (partial pad-fn "25px"))) — now you can say (margin-and-padding some-style) and have both margins and padding added consistently.

tom22:05:00

@mattsfrey: I've come across this as well, usually working with hiccup. Coming from within HTML or some other templating library, one's mind sort of gets stuck thinking we can resolve sibling nodes in place. Have you tried treating the hiccup as a plain old data structure instead and using tools like into or reduce?

mattsfrey22:05:10

I mostly do hiccup as plain data - we just have one particular use case where we have decided to set default styles in components as top/bottom/right/left so they can be overridden individually, and I wanted just a helper function/macro to allow doing the shorthand

mattsfrey22:05:23

when overriding them

mattsfrey22:05:30

(and defining them really)

seancorfield22:05:48

Inside the function you could merge the specified styles over the defaults, so (pad-fn "25px" {:color "blue" :padding-top "10px"}) would only fill in padding for bottom, left, and right.

seancorfield22:05:34

(defn pad-fn [size style] (merge {:padding-top size :padding-right size :padding-left size :padding-bottom size} style))

mattsfrey22:05:41

yeah I basically wanted to avoid doing mergings and various ops, this is literally just about saving keystrokes and enhancing readability etc, was going to have multiple instances of these “helpers” for margin and other styles etc