This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-16
Channels
- # admin-announcements (2)
- # bangalore-clj (3)
- # beginners (15)
- # boot (303)
- # carry (18)
- # cider (7)
- # cljs-dev (222)
- # cljsrn (103)
- # clojure (196)
- # clojure-czech (2)
- # clojure-russia (69)
- # clojure-spec (21)
- # clojure-uk (48)
- # clojurescript (68)
- # cursive (18)
- # datomic (185)
- # events (1)
- # hoplon (2)
- # lambdaisland (1)
- # leiningen (1)
- # mount (10)
- # off-topic (1)
- # om (14)
- # onyx (154)
- # parinfer (1)
- # pedestal (3)
- # planck (5)
- # protorepl (9)
- # re-frame (17)
- # reagent (27)
- # ring (2)
- # specter (58)
- # test-check (1)
- # testing (7)
- # untangled (59)
- # yada (35)
I want the route to match to a var, which contains a function that renders the correct HTML
(def app-routes
["/" {"" :home-page
"about" :about-page
"dev" :dev-page
"login" :login-page}])
(def route-match
{:home-page #'pages/home-page
:about-page #'pages/about-page
:dev-page #'pages/dev-page
:login-page #'login/login-page})
bidi accepts keywords, functions and (I believe) vars. I will check
bidi.cljc:183Uncaught Error: No protocol method Matched.resolve-handler defined for type cljs.core/Var: [object Object]
Probably just a case of whoever did the cljc didn't know about cljs.core/Var (or it didn't exist then? not sure!)
@jethroksy: It's probably best if you try and make the patch yourself, and test it on your own codebase by using lein install
There are some tests which do run on cljs, so maybe we need some tests which use vars there too.
Send the PR and I'll backfill the tests if necessary
https://github.com/juxt/bidi/blob/master/test/bidi/bidi_test.cljc#L10 this might be where to add it
Perhaps a fn at the top of this file which gets referred via #'var-test-handler
or something.
(def app-routes
["/" {"" #'pages/home-page
"about" #'pages/about-page
"dev" #'pages/dev-page
"login" #'login/login-page
"register" #'registration/register-page}])
#?(:clj (def app-handler
(->> app-routes
(w/postwalk #(if (var? %) (layout/render-index %) %))
make-handler)))
Then in another file I do:
(def app-routes
(routes
#'app-handler
#'service-routes
(route/not-found
(:body
(error-page {:status 404
:title "page not found"})))))
Thanks for the PR.