API for noir.core - Noir ()


Usage:
(ns your-namespace
  (:require noir.core))

Overview

Functions to work with partials and pages.

Public Variables and Functions



compojure-route

function
Usage: (compojure-route compojure-func)
Adds a compojure route fn to the end of the route table. These routes are queried after
those created by defpage and before the generic catch-all and resources routes.

These are primarily used to integrate generated routes from other libs into Noir.


custom-handler

macro
Usage: (custom-handler & args)
Adds a handler to the end of the route table. This is equivalent to writing
a compojure route using noir's [:method route] syntax.

(custom-handler [:post "/login"] {:as req} (println "hello " req))
=> (POST "/login" {:as req} (println "hello" req))

These are primarily used to interface with other handler generating libraries, i.e. async aleph handlers.


defpage

macro
Usage: (defpage & args)
Adds a route to the server whose content is the the result of evaluating the body.
The function created is passed the params of the request and the destruct param allows
you to destructure that meaningfully for use in the body.

There are several supported forms:

(defpage "/foo/:id" {id :id})  an unnamed route
(defpage [:post "/foo/:id"] {id :id}) a route that responds to POST
(defpage foo "/foo:id" {id :id}) a named route
(defpage foo [:post "/foo/:id"] {id :id})

The default method is GET.


defpartial

macro
Usage: (defpartial fname params & body)
Create a function that returns html using hiccup. The function is callable with the given name.


post-route

macro
Usage: (post-route & args)
Adds a route to the end of the route table and passes the entire request to
be desctructured and used in the body. These routes are guaranteed to be
evaluated after those created by defpage and before the generic catch-all and
resources routes.


pre-route

macro
Usage: (pre-route & args)
Adds a route to the beginning of the route table and passes the entire request
to be destructured and used in the body. These routes are the only ones to make
an ordering gaurantee. They will always be in order of ascending specificity (e.g. /* ,
/admin/* , /admin/user/*) Pre-routes are usually used for filtering, like redirecting
a section based on privileges:

(pre-route '/admin/*' {} (when-not (is-admin?) (redirect '/login')))


render

function
Usage: (render route & [params])
Renders the content for a route by calling the page like a function
with the given param map. Accepts either '/vals' or [:post '/vals']


url-for

macro
Usage: (url-for route-fn & [arg-map])
given a named route, i.e. (defpage foo "/foo/:id"), returns the url for the
route. If the route takes arguments, the second argument must be a
map of route arguments to values

(url-for foo {:id 3}) => "/foo/3" 
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.