This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-26
Channels
- # arachne (4)
- # beginners (70)
- # bigdata (1)
- # boot (373)
- # braid-chat (3)
- # cider (4)
- # cljs-dev (10)
- # cljsjs (6)
- # cljsrn (27)
- # clojars (11)
- # clojure (114)
- # clojure-austria (1)
- # clojure-czech (2)
- # clojure-dusseldorf (2)
- # clojure-greece (7)
- # clojure-italy (2)
- # clojure-nl (6)
- # clojure-russia (15)
- # clojure-serbia (11)
- # clojure-spec (92)
- # clojure-uk (5)
- # clojurescript (183)
- # component (9)
- # cursive (28)
- # datomic (36)
- # editors (4)
- # emacs (1)
- # garden (11)
- # hoplon (155)
- # lein-figwheel (7)
- # mount (47)
- # om (97)
- # onyx (25)
- # proton (3)
- # rdf (3)
- # re-frame (80)
- # reagent (9)
- # ring-swagger (9)
- # spacemacs (1)
- # untangled (145)
- # vim (2)
Hello everyone. I was wondering if there's a catch when one tries to define a macro in a hoplon project.
I created a macros.core file, the content of which seems to be compiled, e.g. I get different errors when changing the file 🙂
@xssive220 you're familiar with the way clojurescript macros work already?
now, when you do (:require [javelin.core])
in your own project you can use both the cljs definitions and the macros
They're basically merged into that same namespace, although of different compiler-origin?
So I should have no problem creating a macro for complex (defc=..) incantations.. It's just that my (ns..) stuff is probably wrong?
so most of the time macro expansion in clojure emits code that can be massaged to work automatically in clojurescript
Brilliant... I'll start with a web page on clojurescript macros then, to make sure I get the difference
I'll do that, thanks... Awesome to be working with something and being able to talk to developers...
oh btw, if you're going to be writing macros around javelin cells, do you already know about the formula
function?
the idea being that the formula
function takes a function as its argument, and returns a formula cell constructor
so when you make macros you usually want to deal with the underlying real functions, rather than more macros
the benefit of working with functions instead of macros is that you're able to use all the lisp things, you can use apply
, etc
Which would be great, because I would want to use the macro with map, which I know to be impossible.
Thank you very much... Coming year I intend to make a living out of developing web applications, so I'm studying a lot now
More demo’s at this weekends Free Code Camp in YEG! 🙂
Curious if anybody has done much SVG work with Hoplon? I’ve had a lot of success getting SVG working but <use> elements aren’t working. They work great if I serialize the HTML document I get from Hoplon into a static HTML file and open it from the file system, so I’m wondering if something about how the page dynamically renders is causing the issue.
@keithsparkjoy you will need the hoplon.svg
namespace
yup, using that
I’m going to put a simple repro case up on git in case anybody is interested
been pulling my hair out on this one most of the day
So it works with prerender then?
I’m new to Hoplon - how can I test that?
add (prerender)
to your boot task
like boot hoplon cljs prerender
or (comp (hoplon) (cljs) (prerender))
prerender just runs the hoplon page through phantomjs
Cool I’ll give that a whirl thanks @flyboarder
How can I tell if (prerender) is doing anything different? I just added that to my boot dev task, reran boot dev, and I’m not seeing anything different...
Ahh I see - need to install phantomjs 🙂
Okay I’m getting a flash of what I expect to see with (prerender) although the client scripts seem to still replace all the content a fraction of a second later.
So the problem shows up again. But yea, it behaves differently with (prerender).
@keithsparkjoy demo repo?
Working on it - will post a link once it’s up
@keithsparkjoy yeah for sure an issue with using use
@keithsparkjoy I think it’s a problem with the xlink:href
attribute, editing your original code in browser (removing the use and then manually adding it) works!
Weird stuff, huh
I think hoplon thinks there should be a xlink namespace
which would be correct since :xlink:href
isnt a proper keyword
like a Clojure namespace or an XML namespace?
clojure
It’s weird because Hoplon does render it properly “xlink:href"
yeah I think the issue is how it’s rendered, i dont know too much about svg but I imagine we need to implement namespaced keyword differently for XML style attributes
like :xlink:href
vs :xlink/href
is xlink the standard namespace?
I think so. I think there’s actually an XML namespace definition for it in the extra dev-related goop that Hoplon puts in the output
You know how Hoplon pops up that little icon at the bottom when it detects a change and pulls the HTML resource again?
That includes it 🙂
thats part of cljs-reload actually, not hoplon
ahh okay
Hmm. Is there a way in Hoplon to emit an attribute without using the keyword syntax?
maybe I could try that.
vanilla js
hoplon just wraps the documentcreate method (well it does other things too :P)
sorry createelement
Yeah your document currently doesnt have a namespace prefix for xlink
so the elements need to be created with the namespace as well
Thanks guys - some ideas for exploration
im trying to set the prefix, will report back
I think :foo:bar is a valid keyword in Clojure… I dunno - just built a little app with lein new app and ran (prn :xlink:href) and it didn’t choke at least 🙂
yes because a keyword can be any character
ex. (keyword "Hello World")
is valid but produces something you cant really use since there is a space
oh that threw an error hmm
@keithsparkjoy try :xmlns:xlink "
as part of your html tag
No change for me
actually that fails for me still, probably because we still arnt using setAttributeNS
actually I think it’s supposed to be this
xmlns:xlink="http://www.w3.org/1999/xlink"
let me try that
no dice
yeah we will need custom attribute handling for these i think
I’ll try what Micha suggested to see if that makes any diff
maybe I can figure out how to replace the svg/use defelem to deal with this
What you probably want is a custom attribute (defmethod hoplon.core/do! :xlink:href [elem kw val] …)
then use (as micha suggested) setattributeNS on the elem part of that
Cool I’ll explore that.
yeah I think we can add something like that to the hoplon.svg namespace once we know it works
@keithsparkjoy @micha working 😛
that was actually much easier than I thought
Sweet! I’ll give it a try.
just add that to the top of your index page above the html part
Thanks guys - you rock 🙂
thank micha, he taught me all my hoplon and cljs knowledge 😛
he’s been patient with me so far 🙂
I’ll throw something together to fix this for other prefixed keywords
@keithsparkjoy here is a version you can use for all the xlink attributes
change the attribute in hoplon to :xlink/href
or whichever you need
Nice clean soln. Will try it out tomorrow :)