Skip to content

How to change the default layout

macourtney edited this page Sep 13, 2010 · 4 revisions

Added for version: 0.4

By default, Conjure includes some extra view code called a layout, which wraps around any of the views you create to make each page look consistent. The default layout is called application.clj and can be found in the app/views/layouts directory.

The Default Layout

A layout looks just like any other view you’ve seen or created, but takes exactly one argument called body. The body is the part of the view rendered by your action’s view. In the default application.clj layout, the body is simply inserted in the content div. All of the header, footer and sidebar information is built around it.

If you want to change the default layout around, simply update the application.clj file. For example, to change the title of your app, you can update the line:

  (let [title "Conjure"]

To something like:

  (let [title "My Awesome App"]

Rendering Your Own Layout

If you have a specific layout for one view, you can render the layout by passing a parameters map to your render-view call in the controller action of that view.

For example, in the action “show”, to render a layout called “show-layout” use:

(defn show [request-map]
  (render-view { :layout "show-layout" } request-map))

Sometimes you may not want to render a layout at all. For example, when the action is called from an ajax request. To tell Conjure not to render a view, simply pass nil as the view:

(defn show [request-map]
  (render-view { :layout nil } request-map))
Clone this wiki locally