This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-05-07
Channels
- # admin-announcements (1)
- # arachne (1)
- # beginners (11)
- # boot (72)
- # cider (7)
- # cljs-dev (9)
- # clojure (31)
- # clojure-czech (8)
- # clojure-poland (1)
- # clojure-russia (7)
- # clojure-uk (17)
- # clojurescript (48)
- # community-development (5)
- # cursive (2)
- # data-science (1)
- # datascript (3)
- # datavis (1)
- # datomic (4)
- # devcards (45)
- # docker (3)
- # hoplon (5)
- # keechma (3)
- # lein-figwheel (1)
- # leiningen (4)
- # luminus (16)
- # off-topic (1)
- # om (2)
- # om-next (1)
- # onyx (4)
- # other-languages (104)
- # overtone (1)
- # re-frame (2)
- # reagent (37)
- # rum (35)
- # untangled (4)
- # yada (4)
how can I coerce the numeric values sent in a request to come in as numbers and not strings?
@yogthos: hey there, would you happen to know? ^
@thug.nasty: the best way would be to use compojure-api
@yogthos: would I then add this to my defroutes entry?
clj
(POST "/" request
:params [a :- Num,
b :- Num,
c :- Num]
(process-request! request))
Yeah should look something like that, I believe you have to specify the type of params, e.g: :query-params
In regular compojure you can also do [x :<< as-int]
. as-int is defined in compojure.coercions
i have a lot of form parameters that appear in two different maps
if I want to keep the map format, do I destructure it as a map with values of specific types?
also, how do I refer to the request that has had the values coerced?
also, do I need to specify the types of all values in the map, or just the ones I want changed?
this is what I’ve done: http://pastebin.com/awmV9cHy
I’ve tried creating a schema, and seeing if that worked
I’m obviously doing something wrong
Quick question re: templating: I'm using hiccup, but trying to combine it with selmer in order to take advantage of the generated templates. So I'm writing a fn that lets you substitute html-ized hiccup into your html-ized selmer, using string/replace. The problem is that, having done that, newlines end up rendering as literal \n
on the page. Is there some standard luminus/selmer/hiccup way to get around that? Or is it just a Bad Idea to call string functions on the output of (render template)
?