Fork me on GitHub
#clojurescript
<
2015-10-09
>
wildermuthn03:10:36

Anyone interested in inline-css styling? We’ve been working on a project that’s meant to replace sass/less with cljs, and I’m pushing my company to let us open-source it, as it’s really limited right now and we’re probably suffering from tunnel vision. But here’s the general direction: https://gist.github.com/wildermuthn/178dee2896a833e7c362

wildermuthn03:10:08

defdiv first constructs a map of css styles with garden + cljs functions, then uses goog.style to add a generated classname, then returns a keyword for use in reagent, like :div.modal-header.

redbeardymcgee05:10:07

I'm really just looking for enlive style css templating

redbeardymcgee05:10:43

with no ties to reagent, react, what have you

shaun-mahood05:10:51

@wildermuthn: super interested in that, I've been using both garden and reagent and want to start moving a lot of my css to inline.

redbeardymcgee06:10:00

That does look pretty useful

Pablo Fernandez08:10:37

Anybody doing forms with re-frame? How do you do it?

bensu13:10:15

@wildermuthn: looks interesting. My feedback would be, try to offer an API that can be used from any DOM templating API (React or not) and then on top of that build specific variants (Hiccup, Enlive, etc.)

wildermuthn13:10:24

@redbeardymcgee, that makes sense to avoid coupling to reagent. The functions could be modified to return the generated class as a string, but I’m not familiar enough with Om to know if that would be useful.

wildermuthn13:10:23

@bensu: thanks! I’ve used Enlive for scraping, and you’re the second person to mention it. I’ll check it out.

gerrit13:10:10

has anyone tried to use the figwheel component as described here: https://github.com/bhauman/lein-figwheel#scripting-with-component ?

gerrit13:10:45

should it be possible to connect the repl-api/cljs-repl to that server?

gerrit13:10:11

if I start the cljs-repl within the REPL that started the server it shows this: cljs.user=> DEBUG: unknown status need-input

bhauman13:10:17

@gerrit: you are using nREPL?

gerrit13:10:45

I guess so, it is a lein repl :headless

gerrit13:10:06

which I connect to via a remote repl in cursive

bhauman13:10:56

Sorry man this is frustrating, I spent a lot of time writing and clarifying this. Please see the docs in the readme above about editor REPLs.

bhauman13:10:52

Above the scripting section.

bhauman13:10:08

No problem this is impossible. Already gotten 3 other folks asking same question. I'm going to clarify it further.

gerrit13:10:05

didn't see that section, only looked at https://github.com/bhauman/lein-figwheel/wiki/Running-figwheel-in-a-Cursive-Clojure-REPL but couldn't connect that to the component based setup

bhauman13:10:23

@gerrit you could replace the script in that tutorial with the component script in the readme

gerrit13:10:34

alright, thanks. what I am trying to get to work is a bit different setup though. I want to start figwheel inside the user.clj, so I can (go) and (reset) everything together

gerrit13:10:53

@bhauman: great, using piggieback it connects just fine. the only thing that is weird is that it prints this after each form: DEBUG: unknown response keys :printed-value

shaun-mahood14:10:26

@gerrit: I had that problem recently too. For me it was a problem with leftover cider-nrepl in my lein profile.

gerrit14:10:22

@shaun-mahood: thanks for the hint, I'll have a look

fdserr14:10:33

(how) is clojure.walk available to cljs, please?

ul14:10:31

as clojure.walk

fdserr14:10:23

perfect, thx @ul

scriptor14:10:49

anywhere here familiar with transit-response-format in cljs-ajax?

scriptor14:10:03

the documentation says that it takes a transit reader parameter

scriptor14:10:13

but according to the source it seems to want an entire request object

scriptor14:10:55

okay, I think what it takes is a map with a :reader key and a :raw key

scriptor14:10:02

let's see if that's right

ddellacosta16:10:53

can any of you folks tell me what I need to set to print stuff out in the CLJS repl using Cider? I’m seeing this and I’m stumped:

org.mozilla.javascript.EcmaError: ReferenceError: "console" is not defined. (rhino.clj#40)

dnolen17:10:00

there is no console object in Rhino

bhauman17:10:02

@dnolen: thinking about making it so that figwheel doesn't respond to clj changes in cljc files https://github.com/bhauman/lein-figwheel/issues/255

bensu17:10:18

@bhauman: very interesting problem. do you have any ideas on how to solve it?

dnolen17:10:14

@bhauman: no opinions about that, to be honest I don’t really understand what Figwheel guarantees wrt. reloading, probably should be written up somewhere

bhauman17:10:18

@bensu: a) make macro reloading optional b) have figwheel treat cljc files like cljs files c) ignore it and go eat some ice cream

dnolen17:10:50

it does seem that if there’s not a knob for the behavior someone will be unhappy

bensu17:10:28

@bhauman: a) seems like the right knob but ice cream is always better simple_smile

bhauman17:10:55

@dnolen @bensu I'm thinking a good knob would be to allow folks to specify a build function

ddellacosta17:10:29

dnolen: yeah, that seems to be what that error is saying…but how do I print something out in cider w/the cljs repl?

ddellacosta17:10:47

(if you know)

dnolen17:10:23

@ddellacosta: this is Rhino stuff, I believe ‘js/print’ or Java printing should work, you need to set *print-fn* to something reasonable for the Rhino environment

ddellacosta17:10:43

okay, I’ll start with that and see what I figure out—thanks @dnolen

timgilbert18:10:40

Hi all, got a clojurescript build-tooling question. I'm using lein cljsbuild to build my cljs files, and I'd like to set it up so that the basic index.html that serves my (static SPA-style) app includes the version number from project.clj.

timgilbert18:10:23

...which I will then use to display to the user and as a cache-busting parameter, eg <script src="app.js?${VERSION}"></script>

timgilbert18:10:28

Anyone doing something like this already? I'm hoping there's a better option than just running sed over my files after the build

bensu18:10:57

@timgilbert: the best solution I found was sed before the build which is used by the compiler itself: https://github.com/clojure/clojurescript/blob/master/script/build#L36

timgilbert18:10:30

Hmm, was hoping to avoid a shell script, but that does make sense

bensu18:10:15

the one thing I ended up doing differently was writing to an almost empty namespace (`app.version`) and not tracking it with git

juhoteperi18:10:26

@timgilbert: If you also have Clojure backend, you could easily generate the index.html from Clojure using hiccup or such, then it's easy to generate script url

bensu18:10:42

otherwise the git index is always dirty after a build

timgilbert18:10:49

Yeah, for this app I'm serving from s3, so no server

timgilbert18:10:45

I do have a deployment step (on circleci) so I can sed the file there without having to muddy the git waters

timgilbert18:10:24

But I was hoping there would be something that would just get my version out of project.clj without me having to grep it out or something

bensu18:10:06

there was a lein plugin somewhere but for some reason I chose not to use it. I wish I could be more helpful

bensu18:10:40

@timgilbert: do you think is a job suitable for environ in cljs?

timgilbert18:10:27

I've used environ on the clj side before, but for some reason every time I tried to use it from cljs it made my head hurt

timgilbert18:10:00

Thanks, though @bensu, hearing that other people have looked for a solution and not found one actually is helpful

bensu18:10:11

I've never succeeded either with environ + cljs, that's why I ask. It might be time to get that working and solve problems like yours

nberger18:10:56

I've used environ from cljs with no issues, except from the fact that you have to be careful to use it from clojure macros only (can't call it directly from cljs code because the environment is not available when in js runtime) which are then called from cljs. Did you have any other issue?

nberger18:10:47

But now I see you want to grab the version from project.clj... that's not something where environ could help

martinklepsch18:10:41

@timgilbert: I’ve seen some boot tasks that help with fingerprinting assets not sure if that’s an option for you

ddellacosta20:10:57

timgilbert, for another option—depends on how you’re serving the HTML, but—we are using enlive to append a cache-buster to the script src which we identify with specific classes.

timgilbert20:10:52

I think for now I will probably just go with a simplistic shell script. Thanks for the suggestions everyone. This does seem like the kind of thing boot would be good at, but I don't have time to rewrite that stuff at the moment.

ddellacosta20:10:08

yep, that’s pretty reasonable I think.

timgilbert20:10:06

I think longer term I might look into a lein task that would use enlive as you suggest, @ddellacosta, assuming I don't rewrite everything in boot

ddellacosta20:10:44

@timgilbert yeah to be clear we are not exactly serving static pages, so it makes sense for us

ddellacosta20:10:12

but if you want to pre-compile your HTML then a boot-based/scripted solution may make more sense (although I suppose enlive could still help there)

cvermilion21:10:13

does anyone know if :closure-defines should work with :optimizations :whitespace? http://dev.clojure.org/jira/browse/CLJS-1389 seems to imply that that should work now, but I can’t seem to get it working

cvermilion21:10:50

it works with :optimizations :none but only if a :main is specified

maria23:10:38

@cvermilion: Yes, should be working with :whitespace. Have a look at @martinklepsch’s blog post for more information: http://www.martinklepsch.org/posts/parameterizing-clojurescript-builds.html