Liking cljdoc? Tell your friends :D

reacl-c-basics.pages.routes

Functions to define and use the routes in a client side routing application.

A typical usage would be to define the routes of an application in a shared cljc file, and use them with a core/html5-history-router in the client, and with ring/wrap-client-routes on the server side to deliver the client code for all of these routes.

You can also call routes as a function, passing the defined path and query params, and get a 'href' back that be use in anchor tags to let the user navigate to the pages of the application.

Functions to define and use the routes in a client side routing application.

A typical usage would be to define the routes of an application in a
shared `cljc` file, and use them with
a [[core/html5-history-router]] in the client, and
with [[ring/wrap-client-routes]] on the server side to deliver the
client code for all of these routes.

You can also call routes as a function, passing the defined path and
query params, and get a 'href' back that be use in anchor tags to
let the user navigate to the pages of the application.
raw docstring

defrouteclj/smacro

(defroute name pattern)

Defines a var with the given name to be a route according the given pattern. Adds it to the a list of routes, if written inside a defroutes macro.

A pattern can be a fixed path "/path/to/page", or can have one or more path arguments "/article/:id".

For example:

(defroute r0 "/home")

(href r0) => "/home"
(parse r0 "/home") => []
(r0 {:lang "de"}) => "/home?lang=de"
(parse r0 "/home?lang=de") => [{:lang "de"}]

(defroute r1 "/path/:id")

(r1 "123") => "/path/123"
(parse r1 "/path/123") => ["123"]
(parse r1 "/other/path") => nil
Defines a var with the given `name` to be a route according the given `pattern`.
   Adds it to the a list of routes, if written inside a [[defroutes]] macro.

A pattern can be a fixed path `"/path/to/page"`, or can have one or more path arguments `"/article/:id"`.

For example:

```clojure
(defroute r0 "/home")

(href r0) => "/home"
(parse r0 "/home") => []
(r0 {:lang "de"}) => "/home?lang=de"
(parse r0 "/home?lang=de") => [{:lang "de"}]

(defroute r1 "/path/:id")

(r1 "123") => "/path/123"
(parse r1 "/path/123") => ["123"]
(parse r1 "/other/path") => nil
```
sourceraw docstring

defroutesclj/smacro

(defroutes name & defs)
source

hrefcljs

(href route & params)

Returns a URI path for the given route and concrete values for all parameters. The last parameter may be a map of query params.

This is the same as calling the route as a function.

Returns a URI path for the given route and concrete values for all
parameters. The last parameter may be a map of query params.

This is the same as calling the route as a function.
sourceraw docstring

parsecljs

(parse route uri)

If the given URI matches the given route, returns a vector of all path arguments and optionally a map of query params.

If the given URI matches the given route, returns a vector of all path arguments and optionally a map of query params.
sourceraw docstring

routable?clj/s

(routable? v)

If v is a value returned by route of bound to a name with defroute.

If `v` is a value returned by [[route]] of bound to a name with [[defroute]].
sourceraw docstring

routeclj/s

(route pattern)

Returns a route for the given URL pattern. Note: Prefer defroute below.

Returns a route for the given URL pattern. Note: Prefer [[defroute]] below.
sourceraw docstring

route-matchesclj

(route-matches route request)
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close