Skip to content

How to change the default layout

macourtney edited this page Sep 13, 2010 · 4 revisions

Added for version: 0.4
Updated for version: 0.7

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 def-view call in the view file.

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

(def-view { :layout "show-layout" } []
  [:div "Show"])

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 layout for a view, simply set :no-layout to true.

(def-view { :no-layout true } []
  [:div "Show"])
Clone this wiki locally